locked
How can I get UTC date time values (like UTC year, UTC month and UTC day) in C++/CX for Windows Store application

    Question

  • Hi C++ fellows,

    I have a question about how to get the UTC date/time values (like year, month, day) of now in C++/CX for windows store application. I’m trying to write a C++ based windows runtime library for a windows store application (javascript based). So far I have tried the following code which can help get the datetime and corresponding values for local “Now” date/time. But how can I get the UTC values (the DateTime::UniversalTime only returns a long value which is not usable)? Or is there any means to get the current timezone offset so that I can manually calculate it (by adding the timezone offset on the local now date/time)?

    auto c = ref new Windows::Globalization::Calendar();
    c->SetToNow();
    // the following code result to the local date values(not UTC ones)
    int yearNow = c->Year;
    int monthNow = c->Month;
    int dayNow = c->Day;

    Thanks in advance!

    Regards,

    Steven


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, November 26, 2012 2:26 AM

Answers

All replies