Skip to main content
gamedev.net
🔒 Locked

Date/Time as std::string in C++

Started by PaleRaider 1 reply 750+ views
Original Post
PaleRaider
PaleRaider
Does anyone know of a simple way to get the current date and time as a std::string in C++?
Zipster
Zipster
To the best of my knowledge, the C++ Standard library doesn't have its own time management libraries, yet you can include the <ctime> header to wrap <time.h> into the std namespace. Then, just do something like this:

using std::string;
using std::ctime;
using std::time;

string datetime( ctime( time(0) ) );


[edited by - Zipster on March 14, 2003 7:44:34 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.