Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Visual Studio Console Date & Time

Status
Not open for further replies.

bont

Programmer
Sep 7, 2000
200
US
I have been looking everywhere for a simple way to do this, including here. Can anyone please answer this question?

I am using MS Visual Studio 6.0 C++, and I am just writing a console application (NO MFC). All I need to do is retrieve the system date and time, and store them into strings, to be manipulated later. Could someone please show me what libraries to add, and how to store them into the strings. There are so many ways out there, and none of them seem to be working.

Thanxs
 
Use _strdate(char *datestr) in time.h header file. It copies the date to a buffer pointed by datestr, formatted in mm/dd/yy.

Try it out. Hope it helps

raochetan
 
OK , I'm sorry, but this doesn't make any sense to me. I usually declare my strings as char MyString[], and not char *MyString; How do I convert back and forth. And again, I have MS Visual Studio, which seems not to have time.h but ctime.h. Any help?
 
time.h is available in MSVC. There is an example in _strdate doc. In short, you can do:

char MyString[9];
_strdate(MyString);


HTH
Shyan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top