By Alvin Alexander. Last updated: February 22, 2022
As a brief note, if you need a Dart function to get the current date/time (DateTime
) in a “seconds since the epoch” format, I can confirm that this function works:
/// the current time, in “seconds since the epoch” static int currentTimeInSeconds() { var ms = (new DateTime.now()).millisecondsSinceEpoch; return (ms / 1000).round(); }
I just tested that with some Flutter database code I’m working on, and it returns the same number of milliseconds since the epoch, which is what I get from a SQLite database.