CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 1999
    Gastonia, NC

    Time Zones and CTime

    How can I get the time information
    from a computer on the network that's
    in a different time zone?

    Here's my situation:
    987081187.dat resides on a host machine
    somewhere in the world, my app pulls
    this accross a network, and needs to be
    able to know what time this is on the
    remote host, not it's own local time.
    Is there a way to query this information
    from the remote machine? The time and
    time zone for that machine, then I can
    modify the difference in the CTime with
    this info.

    So what might happen, is the remote might
    need to search for 12/12/2001 12:05PM based
    on the time on the remote host. So I was
    hoping to have my app, after showing a browse
    dialog for them to pick a location, to query
    for the appropriate info from that machine,
    so it could modify searches based on the return


    AIM/AOL: EdisonCPP
    ICQ: 39184886 - ID EdisonCPP
    Email: edisoncpp@carolina.rr.com

  2. #2
    Join Date
    Oct 2011

    Re: Time Zones and CTime

    Due to a glitch in _get_daylight (see http://connect.microsoft.com/VisualS...call-to-mktime)

    the code looks something like this:

    struct tm daylightfix;
    time_t now;
    daylightfix = *localtime(&now);
    CTime curr = CTime::GetCurrentTime();
    CTime est = CTime(curr.GetTime()+((5+dst_hour)*60*60));
    MessageBox(curr.Format("%Y-%m-%d %H:%M:%S") + "," + est.Format("%Y-%m-%d H:%M:%S"));

    For me, since I'm HST, we don't observe DST, so curr time adjusts accordingly for the est when done this way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.