Click here to Skip to main content
12,756,303 members (34,136 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++/CLI .NET

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;

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
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++:[^]

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2017
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