Simple CTime question
-
I need to know if I am understanding this properly: If I want to display the time (in text) for a given number of seconds (dwSec) since Jan1, 1970 (in UTC), would I need to adjust the dwSec for the difference in time zones first before calling CTime::Format()? Does this look right?: DWORD dwSec = 1045688797; //Feb 19 21:06:37 2003 UTC (I think) CTime tLoc((time_t)dwSec); CString szLocal = tLoc.Format("%m/%d/%Y %H:%M:%S"); //Adjust for time zone diff before calling CTime::Format //for UTC in text format: dwSec += (tzinfo.timezone * 60); //Adjust for DST: if (tzinfo.dstflag) dwSec -= 3600; CTime tUTC((time_t)dwSec); CString szUTC = tUTC.Format("%m/%d/%Y %H:%M:%S"); If there is a better way, I would appreciate any tips, but I still need to know if the above is correct. Thank you very much.