Reputation: 112
I have a question: How to work with Date Time Type in VC++. I search many times and only found a solution:
time_t t = time(NULL); // get time now
struct tm * now = localtime(&t);
But I don't know how to set a Date with a specify value, example:
oDay = new DateTime("5, 6, 10, 5, 6, 2005");
I want to build a code that set a date with a specified value and check this value is valid or not. Anyone plz help me. Thank for all support!
Upvotes: 0
Views: 976
Reputation: 11953
Use the COleDateTime
class.
The ParseDateTime()
function converts date-time strings in a variety of formats into COleDateTime
- returning false
if the string is not valid.
You can create a COleDateTime
containing a specific date-time simply like this:
COleDateTime oDay(2005, 6, 5, 10, 6, 5);
Upvotes: 1