Skip to content

DateTime millisecondsSinceEpoch inconsistency with emulator #103908

@woolfman007

Description

@woolfman007

Hi all,

first I wanted to point out that Flutter is an amazing piece of software. I've seen quite some UI frameworks during my career, but this one basically blew my mind.

But, I encountered something strange. As far as I understand it, DateTime.millisecondsSinceEpoch must be timezone agnostic. That means, that

        var tsu = DateTime.now().toUtc().millisecondsSinceEpoch ~/ 1000;
        var tsl = DateTime.now().toLocal().millisecondsSinceEpoch ~/ 1000;

must report the same number (unless by some coincidence, the two calls fall into different 1000s bucket, but let's forget about that for a moment). So, millisecondsSinceEpoch is a universal number, regardless on which device and from which timezone it is called. That's what the definition says: "The number of milliseconds since 1970-01-01T00:00:00Z (UTC)"

And yes, both values are the same in my tests, like one would expect. But, the result of the above code differs between my Android emulator and a real device. The real device and the browser version show the correct value as seen on https://www.unixtimestamp.com/ while the emulator is one or two hours off. I guess the emulator queries the Windows API in the end and uses local time instead of UTC by accident.

Not a deal breaker for me (since the real device works correctly), but would be nice if it worked on the emulator, too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage teamwaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions