Solved

Proper date and time formate

Posted on 2002-04-16
2
324 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now