Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++/CLI .NET WinForm
Hello!
 
i want to konw how to write this under 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 25-Sep-12 5:03am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It is exactly the same:
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[^]
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,127
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100