Search Issue Tracker

Fixed in 2021.1.X

Fixed in 2019.4.X, 2020.1.X, 2020.2.X

Votes

31

Found in

2017.4.0f1

2018.4.0f1

2018.4.6f1

2019.2.0a1

2019.3.0a1

2020.1.0a1

Issue ID

1179945

Regression

No

[WebGL] DateTime.ToLocalTime() does not convert to local time in build when using Chrome/Firefox/Opera browsers

WebGL

-

How to reproduce:
1. Open the attached project ("case_1179945-DateTimeBug.zip")
2. Open the repro scene ("SampleScene")
3. Enter play mode and notice that local time is displayed correctly
4. Switch platform to WebGL
5. Make a build and run it

Expected results: Local time is displayed correctly
Actual results: Local time is not displayed correctly

Reproducible with: 2017.4.32f1, 2018.4.8f1, 2019.2.3f1, 2019.3.0b1, 2020.1.0a2
Reproducible with browsers: Chrome (76.0.3809.132 (Official Build) (64-bit)), Firefox (68.0.2 (64-bit)), Opera (63.0.3368.53)
Not reproducible with Edge (42.17134.1.0)

  1. Resolution Note (fix version 2021.1):

    Fixed in 2021.1.0a1

  2. Resolution Note (fix version 2020.2):

    Fixed in Unity 2020.2.0b11

  3. Resolution Note (fix version 2020.1):

    Fixed in 2020.1.14f1

  4. Resolution Note (fix version 2019.4):

    Fixed in Unity 2019.4.14f1

Comments (2)

  1. asween16

    Nov 26, 2019 14:29

    Forgot to add code clip.

    public static class DateTimeHelper
    {

    /// <summary>
    /// Method to retrieve milliseconds since epoch
    /// </summary>
    /// <returns>
    /// Milliseconds since epoch
    /// </returns>
    public static long getMillisecondsSecondsSinceEpoch()
    {
    return (long) DateTime.Now.ToUniversalTime().Subtract(
    new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)
    ).TotalMilliseconds;
    }
    }

  2. asween16

    Nov 26, 2019 14:28

    We are having a problem where getting a call to DateTime.Now.ToUniversalTime is failing. Very infrequently we see a timestamp that is earlier than current time.

    What actually is the behavior when this fails? Is the bug only for DATETIME.TOLOCALTIME?

    We are on Unity Version 2018.3.14f1 and Chrome Version 78.0.3904.108 (Official Build) (64-bit).

    The error is very infrequent but serious when it happens.

    Is there a fix planned or a specific release of Unity that is more reliable?

    I don't see case_1179945-DateTimeBug.zip in this link to download. Is there another way to reproduce?

    Thanks
    Andy

Add comment

Log in to post comment