troubleshooting Question

Getting GMT time into a CTime

Avatar of azami
azamiFlag for Japan asked on
System Programming
5 Comments1 Solution1727 ViewsLast Modified:
When our server passes time/date values to clients, it does so in a formatted string representing the time in GMT (UTC).  It's easy to get UTC from a CTime object with FormatGmt(), but there does not seem to be a way to put UTC back into another CTime object after we parse that string.  Any time that I give to CTime seems to be interpreted as local time.

A clumbsy workaround is to store the original values of _timezone and _daylight (global variables in C runtime), set them to 0, construct my CTime object, then restore the variables.  This works, but is ugly and obviously not threadsafe.

Can anyone offer a better alternative?

In short, I'm looking for a function like:

CTime GetCTimeFromGmt(int year, int month, int day, int hour, int minute, int second)

where the passed parameters are relative to GMT.  The function must be thread safe.


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros