I would like to spit a date/time string (for example 1/08/1957/11:20:01
, or any type of time format) into month, hour, second, minute. The problem is that firstly I don't know how to define a type of time that can be split.
Should I write:
time_t now=1081987112001 s; //it is not correct. why? what's the c++ time data format?
struct tm* tm = localtime(&now);
cout << "Today is "
<< tm->tm_mon+1 // month
<< "/" << tm->tm_mday // day
<< "/" << tm->tm_year + 1900 // year with century
<< " " << tm->tm_hour // hour
<< ":" << tm->tm_min // minute
<< ":" << tm->tm_sec; // second
But it's not correct. Can someone give me an example with a method that takes a time value given from the keyboard and splits it?
What are the types of data times formats that c++ can accept?