Link to home
Start Free TrialLog in
Avatar of HotRod40
HotRod40

asked on

Date Formatting

I have written a program in Visual C++ that has a DateTimePicker and a button.
When I click the button In want the date that has been selected in the DTPicker to
be shown in a message box in the format of dd/mm/yy.

I am new to VC++ and any help would be greatly appreciated.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Salte
Salte

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bkrahmer
bkrahmer

AlexFM, you seem to have ignored Salte's statements about localization.  The GetDateFormat function formats a date as a date string for a specified locale.  Check that out.

brian
Anyway, if HotRod40 wants it in the specific format dd/mm/yy the method shown by AlexFM is one way to do it.

However, be aware that if your program is to be locale dependent you should NOT use that format. In that case the format should probably be "according to locale" and so you should rather use whatever format the locale tells you to use. MFC has functions to automatically format a time "according to locale" and you should most probably use those functions instead.

Alf
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split points between Salte & AlexFM

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer