locked
How to get and set Datetime value in c++ windows store app

    Question

  • I would like to create a sample for datetime functionalities in c++ windows runtime components, Here I tried with Windows::Foundation::Datetime and calendar, by using I can get current date functionalities, but I can't able to get and set datetime valriables by using string to datetime convertion, Anyone knows please help me to find the solution.
    Saturday, November 16, 2013 10:49 AM

Answers

All replies

  • You can generate a DateTime from a string with the DateTime.Parse Method (String) .

    Also take a look at the DateTimeFormatter class to parse the string into date and time parts as strings.

    --Rob

    Saturday, November 16, 2013 3:57 PM
    Owner
  • Thanks for your reply,

    In windows store app using visual c++ windows runtime component application, I found only two namespaces

    1.Windows::Foundation::Datetime -- > there is no methods and properties  under this "DateTime"  because its a value not a class.

    2.Windows::Globalization::DateTimeFormatting--> here DateTimeFormatter class constructors accepts string values as calendar. but i have a string value as  concatenating  three integer values with "/" symbol,

    so how can i set datetime value ,to parse string to date and time ? 

     

    Monday, November 18, 2013 7:22 AM
  • My apologies Malar. I read your initial post as C#, not C++.

    I believe for C++ you'll need to parse the string yourself. You can call GetLocaleInfoEx with the LOCALE_SSHORTDATE or LOCALE_SLONGDATE constants to find the format and then use that to understand the string.

    --Rob

    Tuesday, November 19, 2013 8:07 PM
    Owner