Solved

Proper date and time formate

Posted on 2002-04-16
2
327 Views
Last Modified: 2013-11-20
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
Comment
Question by:habibb
2 Comments
 
LVL 4

Accepted Solution

by:
pagladasu earned 7 total points
ID: 6946445
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
 
LVL 37

Expert Comment

by:zzynx
ID: 6946947
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Macro to save highlighted rows as a separate file 5 45
windows 10 how make picture as desktop background 2 65
only14 challenge 19 81
Change to event 1 119
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question