Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Simple CTime question

Simple CTime question

Scheduled Pinned Locked Moved C / C++ / MFC
question
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dave_
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups