saturngod
saturngod

Reputation: 24949

convert timezone in Windows Phone 7

I want to convert "Asia/Singapore" timezone to "America/Virgin".

But FindSystemTimeZoneById is not include in windows phone 7 sdk. Is there any way to convert one timezone to other timezone ?

I can't write custom time zone converter because I don't know about daylight saving for timezone.

In WP7 SDK only include TimeZoneInfo.Local and TimeZoneInfo.Utc.

Upvotes: 1

Views: 903

Answers (2)

Isaiyavan Babu Karan
Isaiyavan Babu Karan

Reputation: 987

I am not sure but you can try following workaround solution

TimeSpan ts = DateTime.Now - DateTime.UtcNow;

var systemTimeZone =  Math.Round(ts.TotalHours, 1); // this will gie time difference in double

var systemTimeZoneText = DateTime.UtcNow.AddHours(systemTimeZone).ToString("hh:mm tt"); // this will give result as 08:53 AM

Upvotes: 0

ColinE
ColinE

Reputation: 70160

There is no easy way to do this, both Silverlight and Silverlight for Windows Phone 7 lack support for timezones. To perform this conversion you are going to have to grab a copy of the tz database and do it yourself.

I would recommend storing all your dates in UTC, then display in UTC or local time. Supporting arbitrary timezones is far too tricky!

Upvotes: 1

Related Questions