Is there a good way to parse milliseconds since epoch (ex. 1486252500000 13 digits) formatted time into a human readable format?
Asked
Active
Viewed 2.8k times
1 Answers
60
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);

Hadrien Lejard
- 5,644
- 2
- 21
- 18
-
Please include the library import path also. I tried "import "package:intl/intl_browser.dart";" – Ajith M A Jul 04 '18 at 12:13
-
@AjithMemana search by the library name at Pub.Dev, also an embedded link has been provided. – Saswata Jul 16 '20 at 10:13