0

I need to convert the Timezone of my windows mobile 6.5 application to UTC in C# 4.0? Is it possible to change the timezone to UTC?

Nasreddine
  • 36,610
  • 17
  • 75
  • 94
Imran Qadir Baksh - Baloch
  • 32,612
  • 68
  • 179
  • 322

1 Answers1

1

You are confusing me. Windows Mobile 6.5 (aka Windows Embedded Handheld) AND C#4.0??????

Windows Mobile 6.5 can be programmed using the Compact Framework 3.5. There is no C# 4.0 version. There is Windows Phone (>=7.x) that can be programmed using a C# 4.0 framework. Latter is done with Visual Studio 2010. Windows Mobile 6.5 should be programmed with Visual Studio 2008 (latest VS with native Mobile support).

OK, when you deal with times, you should know that there are different 'times' known to your device. The main 'time', the system time, is always UTC. For example, filetimes are always saved with UTC. Otherwise switching the time zone would have to be saved to all files. Then there is a another 'time', the local time. For example DateTime.Now() gives the local time, the time with timezone and DST applied.

There are API functions to get/set UTC time of device or to get/set local time and to get/set filetimes.

Playing with SetTimeZone/GetTimeZone I found a big issue in conjunction with DST. See here http://www.hjgode.de/wp/2010/10/08/windows-mobile-setsystemtime-and-dst-einsteins-relativity-theory/. The post also has the P/Invokes to access time functions on Windows Mobile from Compact Framework.

What do you mean by Convert TimeZone to UTC? If you need to to knwo the UTC of a local time, you have to read the TimeZone information and add/remove the timezone offset values to the local time to get the UTC time.

~Josef

josef
  • 5,951
  • 1
  • 13
  • 24
  • Thanks. I have a server on ASP.NET C# 4.0 which have US Timezone and on client I have C# 3.5 which have MEA Timezone. I am thinking to change both server and client timezone to UTC. So that I will not face any time difference issue. Any other way will be appreciable? – Imran Qadir Baksh - Baloch Oct 05 '12 at 17:50
  • I would not recommend to use different time zones than the correct ones. There are some services in background that may change the TZ automatically. At least on Mobile devices the cell radio can tell the time zone and time to the OS and the OS maybe using automatic TZ changes. For example when you travel and cross TZ borders. As said, the system time is always UTC and the local time can be calculated with the computers TZ and DST offset.If you exchange time-stamped data between the clients and host, always use the UTC as time-stamp. – josef Oct 07 '12 at 05:28