Click to See Complete Forum and Search --> : SetSystemTime


Asim Hussnain
October 25th, 2001, 11:32 PM
I'm trying to set the system time.
SCENERIO:
Through Socket, Server sends it current FILETIME to client. Client gets the SYSTEMTIME from the sent time and then call SetSystemTime() using this system time. But the set time is differnt by +/- GMT TIME DIFFERENCE ('coz of the TIME_ZONE). Can somebody suggest how to make it work. (I've tried but could'nt handle Getting Timezoneinfo and Setting timezone info)


Best Wishes
Asim Hussnain
(Intech)

nachum
March 6th, 2002, 04:15 AM
Hi

Here is a code that work in our system.

lJulianTime - long number that hold the julian seconds.

TIME_ZONE_INFORMATION lp;
GetTimeZoneInformation(&lp);
long l = (lJulianTime / 60 + lp.Bias) * 60;
CTime CurrentTime(l);
SYSTEMTIME* SystemTime = new SYSTEMTIME();
SystemTime->wDay = CurrentTime.GetDay();
SystemTime->wDayOfWeek = CurrentTime.GetDayOfWeek();
SystemTime->wHour = CurrentTime.GetHour();
SystemTime->wMilliseconds = 0;
SystemTime->wMinute = CurrentTime.GetMinute();
SystemTime->wMonth = CurrentTime.GetMonth();
SystemTime->wSecond = CurrentTime.GetSecond();
SystemTime->wYear = CurrentTime.GetYear();
BOOL B = SetSystemTime (SystemTime);