How to convert From DateTime to unix timestamp in Flutter or Dart in general
13,696
Darts DateTime
has a property millisecondsSinceEpoch
which should be what unix timestamp is as well.
DateTime.now().toUtc().millisecondsSinceEpoch
Related videos on Youtube
Author by
Ahmed Mostafa
i love computer programming language likes , PHP, MySQL, JavaScript, CSS, HTML, AngularJS
Updated on June 04, 2022Comments
-
Ahmed Mostafa almost 2 years
as you seen in the title i want to convert from DateTime to unix Timestamp in Flutter (Dart Lang).
i saw the static Method that can convert from unix timestamp to DateTime :
DateTime.fromMillisecondsSinceEpoch(unixstamp);
i need the reverse
datatime => unixstamp
Thanks in advance.
-
f0xik over 4 yearsUnix timestamps are in seconds, so you'll need to divide that by 1000.
-
anthares about 2 years^ this should be the correct answer!