Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Hello!

i want to konw how to write this under C++:

C#
DateTime dt = DateTime.Now;
           label1.Text = dt.ToString("ddd/MMMM/yy, hh:mm:ss tt");


i' ve made lots of trying and searched a lot but without results.

Hope you help me.
i think my problem is HOW TO FORMAT THE DATETIME: (msdn has no example for c++)

DateTime^ dt = DateTime::Now;
label1->Text=Convert::ToString(dt);

This works, but the output is : 25.09.2012 16:00:02
What i want, is e.g.: 25/Sep/12 16:00:02 and so on.

Thank you!
Posted

1 solution

It is exactly the same:
C++
DateTime^ dt = DateTime::Now;
label1->Text= dt->ToString("ddd/MMMM/yy, hh:mm:ss tt");

or with your requested output:
label1->Text= dt->ToString("dd/MM/yy, hh:mm:ss tt", DateTimeFormatInfo::InvariantInfo);


And here is the documentation for DateTime.ToString for C++:
http://msdn.microsoft.com/en-us/library/zdtaw1bw%28v=vs.80%29.aspx#Y1026[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900