Search Issue Tracker

Fixed in 2018.2.X

Fixed in 2017.3.X, 2018.1.X

Votes

27

Found in

2017.1.0f3

Issue ID

943047

Regression

No

Projects built with .NET 4.6, DateTime.Now always returns current UTC time regardless of your current local time

Scripting

-

Reproduction steps:
1) Download and open TimeTest.zip project
2) Build and run "TimeTest1.unity" scene on an Android device
-- Notice that time printed is not same as device's current time (few hours difference)

Note: Issue is not reproducible with .NET 3.5 Scripting Runtime Version.

Reproduced with:
2017.3.0a4, 2017.2.0b7, 2017.1.0p4, 2017.1.0a3
5.5 and older versions do not support .NET 4.6 Scripting Runtime Version

Devices under testing:
Samsung Galaxy S7, Android 6.1
LG Nexus 5x, Android 7.0
Samsung Galaxy S4, Android 4.2.2
LG G3, Android 5.0
iPhone SE, iOS 9.3

Not reproducible on Standalone
Reproduced on Android and iOS

Fixed in: 2017.4.1f1, 2018.1.0b12, 2018.2.0a1

Comments (21)

  1. MarkDavidBubacz

    Mar 12, 2018 11:18

    2017.3.1f1
    Still not working on .Net 4.6

    (And i can't vote)

  2. Fillmore

    Feb 27, 2018 18:06

    Thank you to the post by MKDEROYJAN (10, 2018 19:36).
    Unity 2017.3.1f1 still has this issue. Any timeline of the update to fix this?

  3. seanmcbeth

    Feb 27, 2018 02:01

    This is how I'm "fixing" the issue in my current project. It requires an extra method call, which does a JNI call, and it seems that the app needs to be completely running before calling it or else the app crashes.

    https://gist.github.com/capnmidnight/8f36856eb93e8350e4eb06043a4216a4

  4. MikePage_Artrix

    Feb 06, 2018 23:08

    I can also confirm that this is not fixed in 2017.3.0p4 using .net 4.6

    On iOS build System.DateTime.UtcNow and System.DateTime.Now both return the same value.

  5. NorLesny

    Feb 05, 2018 10:12

    In what version of Unity 2017.3 is this bug supposed to be fixed? I checked 2017.3.0f3 and 2017.3.0.p4 and both of those still have the same issue when using .NET 4.6.

  6. mkderoy

    Jan 10, 2018 19:36

    I just wanted to give an update to people waiting on this ticket. A fix is on its way, but in the meantime I've provided a workaround (only works with il2cpp players) here on the forums. Hopefully this helps you be productive while the fix gets landed.
    https://forum.unity.com/threads/datetime-now-is-incorrectly-returning-utcnow-in-net-4-6-version.505347/#post-3307564

  7. moldywarpe

    Dec 05, 2017 22:06

    Still no progress on this one Unity......
    Bumping to hopefully get this resolved as it is a major problem for us :(

  8. TapSlots

    Nov 22, 2017 02:01

    Unfortunately this makes Unity's .Net 4.6 completely unusable. We just went through a migration for 4.6 upgraded a lot of 3rd party libraries and began using some of the new syntax only to find that our iOS notifications all schedule on UTC time. Now, we could hack around this using our own native notifications plugin, or offset the timing knowing that DateTime.Now is messed up. However since iOS Notification Services is a Unity first party supported system, and it broke with this change, my trust has been broken. I cannot trust that there aren't other places that Unity is using DateTime.Now internally that are causing issues that haven't surfaced to us.

    I expect that the official answer will be to hide behind the "Experimental" tag on .Net 4.6, but it seems like with every Unity upgrade something fundamental breaks.

  9. CptDustmite

    Nov 20, 2017 04:54

    Confirm this is happening for us on 2017.2.0f2 - this is a major bug as many of our features rely on local user time.

    Only happens on device, not Editor.

  10. f_sh

    Oct 29, 2017 02:55

    Same here.

    Device
    iPhone 7, iOS 11.0

    TimeZone.CurrentTimeZone returns UTC.
    Not correct Local Timezone.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.