Is there a good way to parse milliseconds since epoch (ex. 1486252500000 13 digits) formatted time into a human readable format?
Convert from epoch to human-readable datemyString := DateTimeToStr(UnixToDateTime(Epoch)); Where Epoch is a signed integer. Replace 1526357743 with epoch. =(A1 / 86400) + 25569 Format the result cell for date/time, the result will be in GMT time (A1 is the cell with the epoch number).
DateTime to TImestampThe millisecondsSinceEpoch property of the DateTime class gives us the number of milliseconds since the “Unix epoch” 1970-01-01T00:00:00Z (UTC). This is the timestamp in milliseconds. If you want the timestamp in seconds, just divide the result by 1000.
Your timestamp is in some local format. import 'package:intl/intl. dart'; var dmyString = '23/4/1999'; var dateTime1 = DateFormat('d/M/y'). parse(dmyString); var mdyString = '04/23/99'; var dateTime2 = DateFormat('MM/dd/yy').
The number of milliseconds since the "Unix epoch" 1970-01-01T00:00:00Z (UTC). This value is independent of the time zone. This value is at most 8,640,000,000,000,000ms (100,000,000 days) from the Unix epoch. In other words: millisecondsSinceEpoch.
DateTime
does have a named constructor for millisecond since epoch
https://api.dartlang.org/stable/1.24.2/dart-core/DateTime/DateTime.fromMillisecondsSinceEpoch.html
DateTime date = new DateTime.fromMillisecondsSinceEpoch(1486252500000)
If you want to convert it to human readable string, you can use intl package with the DateFormat class
import "package:intl/intl_browser.dart"; var format = new DateFormat("yMd"); var dateString = format.format(date);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With