[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 335
  • Last Modified:

Proper date and time formate

Hope every expert will be fine.
i want to get current date and time in the formate like this   04/15/2002 05:25:45 PM or 04/15/2002 05:25:45
tell me simple way because I am new in VC++.
waiting for Good from all experts.
Thanks
0
habibb
Asked:
habibb
1 Solution
 
pagladasuCommented:
CTime tNow = CTime::GetCurrentTime();
CString strNow = tNow.Format("%m/%d/%Y %H:%M %p");

strNow will contain the date and time in the desired format.
0
 
zzynxSoftware engineerCommented:
Just a comment,

Are you sure you want it to be formatted that way?
Doesn't the user of your program expect the format to correspond with his regional settings?

If yes, then just use the most simple form of Format():

COleDateTime odt = COleDateTime::GetCurrentTime();
CString strNow = odt.Format();

Bye.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now