toHumanReadableTimestamp method
Convert this DateTime to a human readable timestamp.
The output is similar to the output from the date
binary from
GNU coreutils.
Example
final date = DateTime(2024, 5, 7, 5, 9, 4);
// Prints "Tue\t7 May 05:09:04 CEST 2024"
// The value of the timezone depends on your region.
print(date.toHumanReadableTimestamp())
Implementation
String toHumanReadableTimestamp([String? locale]) {
final date = this;
// See https://pub.flutter-io.cn/documentation/intl/latest/intl/DateFormat-class.html
var res = intl.DateFormat("E\td LLLL HH:mm:ss ", locale).format(date);
res += "${date.timeZoneName} ${date.year.toString().padLeft(4, "0")}";
return res;
}