how to get the datetime information representing the currenttime zone after the changing the timezone(this time zone change happens when application is running)?
-
8 августа 2012 г. 18:15
Problem Facing with datetime
1.I have started my application with timezone 1(stand alone app)
2.i am using the datetime.now to get the current datetime.this time it is returning time with respect to timezone 1
3.Now i will change the timezone of my system to time zone 2 without stopping my application
4Now my datetime.now returns the current time with respect to timezone 1 not with respect to timezone 2(even the timezoneinfo.local is set to timezone 1)
i have tried it by clearing the system.globalization.culture.currentculture.clearcacheddata and also timezoneinfo.clearcacheddata but i have a problem with these
after i picking the datetime as local time i need to convert this date into other reference timezone 3.
if iam using the above clearing methods the convertion function is failing
Could any please resolve this issue.
thanks in advance
Все ответы
-
8 августа 2012 г. 18:36
What kind of application it is? I don't see such issue in Winforms app. Are the SystemEvents firing in ur app?
SystemEvents.TimeChanged += new EventHandler(SystemEvents_TimeChanged);
--Krishna
-
8 августа 2012 г. 18:39Some time functions return GMT which will always be the same no matter which time zone you have the computer set to.
jdweng
-
9 августа 2012 г. 2:40could you be elaborate because coverttime function is converting the time to time zone 3 properly even the time displaying is with respect time zone 1 after changing the system timezone from 1 to 2.
But it is failed when i clear the cacheddata
no system events are firing -
9 августа 2012 г. 2:43
NO system events are firing
-
9 августа 2012 г. 7:58
I don't think I can give a good answer in this case without seeing some code. with casche data you may of create a new thread that is create ithis issue. You may want to read this webpage below which explains how the cache method works
http://www.asp.net/web-forms/tutorials/data-access/caching-data/caching-data-in-the-architecture-cs
Also the time object returns a time in GMT time. The datetime class has methods that "displays" the time object. Changing the time zone does not effect the "time object", but does effect the datetime class.
jdweng
Added
Note : The timer tick on the computer stores the time in GMT time (not local time). Time sent over the internet is also GMT time. this way when one computer sends another computer a time stamp you don't also have to send the timezone.- Изменено Joel EngineerMicrosoft Community Contributor 9 августа 2012 г. 8:01
- Предложено в качестве ответа Jason Dot WangMicrosoft Contingent Staff, Moderator 13 августа 2012 г. 5:13
- Помечено в качестве ответа Jason Dot WangMicrosoft Contingent Staff, Moderator 16 августа 2012 г. 7:27

