Last updated:
0 purchases
finap datetime helper
Finap Datetime Helper
Features #
Utility functions for Date Time
Getting started #
Run this command to install
flutter pub add finap_datetime_helper
Usage #
Get now as Miliseconds #
static int getNowFromMilliseconds() {
try {
return DateTime.now().toUtc().millisecondsSinceEpoch;
} on Exception catch (e) {
print(e.toString());
return 0;
}
}
copied to clipboard
get Date time from miliseconds #
static DateTime? getDate(int miliseconds) {
try {
return DateTime.fromMillisecondsSinceEpoch(miliseconds, isUtc: true);
} on Exception catch (e) {
print(e.toString());
return null;
}
}
copied to clipboard
get string date from miliseconds #
static String? getDateString(int? miliseconds) {
final formatter = DateFormat('dd-MMM-yyyy hh:mm a');
if (miliseconds == null) return '';
final date = getDate(miliseconds);
if (date != null) {
return formatter.format(date.toLocal());
}
return '';
}
copied to clipboard
get Date in seconds #
static String? getDateInSecondsString(int? seconds) {
final formatter = DateFormat('dd-MMM-yyyy hh:mm a');
if (seconds == null) return '';
final date = getDate(seconds * 1000);
if (date != null) {
return formatter.format(date.toLocal());
}
return '';
}
copied to clipboard
get Only date string by providing miliseconds #
static String? getOnlyDateString(int? miliseconds) {
final formatter = DateFormat('dd-MMM-yyyy');
if (miliseconds == null) return '';
final date = getDate(miliseconds);
if (date != null) {
return formatter.format(date.toLocal());
}
return '';
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.