• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by siddharth3322 · Apr 25, 2016 at 10:56 AM · c#datetimedate

TimeZone Not Found Exception

I want to convert Indian DateTime object to Eastern DateTime object. Means I want to change time zone of particular DateTime object. For this I have written following code:

         string easternZoneId = "Eastern Standard Time";
         TimeZoneInfo easternZone = TimeZoneInfo.FindSystemTimeZoneById(easternZoneId);
 
         string indianZoneId = "India Standard Time";
         TimeZoneInfo indianZone = TimeZoneInfo.FindSystemTimeZoneById (indianZoneId);
 
         DateTime d = TimeZoneInfo.ConvertTime (DateTime.Today, indianZone, easternZone);

When I try to run this statement I am getting, following exception in Console.

alt text

How to run this code? I want to convert my time into eastern time.

screen-shot-2016-04-25-at-42312-pm.png (37.9 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Azaberym · Apr 27, 2018 at 08:25 AM

Here for a late answer: Try to set your Api Compatibility Level to .NET 4.6 in the player settings, that did it for me.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by nicolaspozzi · Mar 29, 2019 at 08:36 PM

The solution above doesn't work for me. Instead, i just use another method, DateTime.UtcNow Example : log.Date = DateTime.UtcNow;

It works for me, it give the exact date that i need

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by nadalizadeh · Aug 24, 2019 at 08:50 AM

Put your .NET version to 4.6 in player settings, the followings are the output in my tests:

 TimeZoneInfo.Local.Id
 Editor: Local
 iOS Device: Local
 
 TimeZoneInfo.Local.DisplayName
 Editor: Local
 iOS Device: (GMT+03:30) Local Time
 
 TimeZoneInfo.Local.StandardName
 Editor: +0330
 iOS Device: +0330
 
 TimeZoneInfo.Local.DaylightName
 Editor: +0430
 iOS Device: +0430
 
 TimeZoneInfo.Local.BaseUtcOffset.Hours + ":" + TimeZoneInfo.Local.BaseUtcOffset.Minutes);
 Editor: 3:30
 iOS Device: 3:30

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

136 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

DateTime.Today for Different Time Zone 1 Answer

Looking For A Better Way To Check If Day Has Passed 1 Answer

Getting the time from a server 2 Answers

FormatException: String can't convert to DateTime ? 0 Answers

how can i make device clock system using datetime and make life system? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges