Last updated:
0 purchases
idkit timeformat
idkit_timeformat #
Introduce #
This is a toolkit for time formatting, which can output time strings in common formats and custom formats.
Function method #
1. Obtain the time output in a defined format through a timestamp in the form of a string.
formString(String time, {String format,TimeUnit timeUnit}) -> String
copied to clipboard
2. Get the output string in the specified format at the current time.
fromNow({String format}) -> String
copied to clipboard
3. Get the string output in the specified format through the digital timestamp.
formInt(String time, {String format,TimeUnit timeUnit}) -> String
copied to clipboard
Unit of time #
/// Time unit.
enum TimeUnit {
microsecond,
millisecond,
second,
}
copied to clipboard
Instance #
1. String timestamp
/// 1. String timestamp
void toStringTimeStamp() {
final String time1 = IDKitTimeFormat.fromInt(timeValue);
print(time1); // 2021-11-30 17:12:00
final String time2 = IDKitTimeFormat.fromInt(timeValue, format: 'YYYY-MM-dd');
print(time2); // 2021-11-30
final String time21 =
IDKitTimeFormat.fromInt(timeValue, format: 'YYYY/MM/dd');
print(time21); // 2021/11/30
final String time3 = IDKitTimeFormat.fromInt(timeValue, format: 'YY-M-d');
print(time3); // 21-11-30
final String time4 = IDKitTimeFormat.fromInt(timeValue, format: 'hh:mm:ss');
print(time4); // 17:12:00
final String time5 = IDKitTimeFormat.fromInt(timeValue, format: 'YYYY');
print(time5); // 2021
final String time6 = IDKitTimeFormat.fromInt(timeValue, format: 'MM');
print(time6); // 11
}
copied to clipboard
2. Current timestamp
/// 2. Current timestamp
void currentTimestamp() {
final String time1 = IDKitTimeFormat.fromNow();
print(time1); // 2021-11-30 17:12:00
final String time2 = IDKitTimeFormat.fromNow(format: 'YYYY-MM-dd');
print(time2); // 2021-11-30
final String time21 = IDKitTimeFormat.fromNow(format: 'YYYY/MM/dd');
print(time21); // 2021/11/30
final String time3 = IDKitTimeFormat.fromNow(format: 'YY-M-d');
print(time3); // 21-11-30
final String time4 = IDKitTimeFormat.fromNow(format: 'hh:mm:ss');
print(time4); // 17:12:00
final String time5 = IDKitTimeFormat.fromNow(format: 'YYYY');
print(time5); // 2021
final String time6 = IDKitTimeFormat.fromNow(format: 'MM');
print(time6); // 11
}
copied to clipboard
3. Timestamp
/// 3. Timestamp
void timestamp() {
final String time1 = IDKitTimeFormat.fromInt(timeValue);
print(time1); // 2021-11-30 17:12:00
final String time2 = IDKitTimeFormat.fromInt(timeValue, format: 'YYYY-MM-dd');
print(time2); // 2021-11-30
final String time21 =
IDKitTimeFormat.fromInt(timeValue, format: 'YYYY/MM/dd');
print(time21); // 2021/11/30
final String time3 = IDKitTimeFormat.fromInt(timeValue, format: 'YY-M-d');
print(time3); // 21-11-30
final String time4 = IDKitTimeFormat.fromInt(timeValue, format: 'hh:mm:ss');
print(time4); // 17:12:00
final String time5 = IDKitTimeFormat.fromInt(timeValue, format: 'YYYY');
print(time5); // 2021
final String time6 = IDKitTimeFormat.fromInt(timeValue, format: 'MM');
print(time6); // 11
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.