Assets\Scripts\Systemz\GameRoute.cs(263,42): warning CS0618: ‘TimeZone’ is obsolete: ‘System.TimeZone has been deprecated. Please investigate the use of System.TimeZoneInfo instead.’
I was getting UNIX time like this
int currentOffset = (int)TimeZone.CurrentTimeZone.GetUtcOffset( System.DateTime.Now).TotalSeconds;
Anyone know a work around to do this with TimeZoneinfo?
I guess i was wrong. I am trying to grab the time offset for the player lol.
This below works for windows and web gl platform. It fails on Android though.
TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
int currentOffset = (int)t.TotalSeconds;
I’m using CultureInfo.InvariantCulture in my game. The code sets a new background and lighting in the morning and resets the scene to night according to the computer time.
TimeZoneInfo localZone = TimeZoneInfo.Local;
int currentOffset = (int)localZone.BaseUtcOffset.TotalSeconds;
I live in Missouri so this returns -21000 for me.
Or if you need display formats localZone.StandardName will return (UTC-08:00) Pacific Time (US & Canada) localZone.StandardName will return Pacific Standard Time. localZone.BaseUtcOffset will return -06:00:00