2

I am trying to get the date and time (NOW) here is what I have got so far:

16/1/2020 13:24

How can I get dd/mm and also how to set time non UTC? The time should be 12:24pm

time_t rawtime
struct tm ltm;
time(&rawtime)

localtime_s(&ltm, &rawtime)

std:stringstream date;
date << ltm.tm_mday
<< "/"
<< 1+ ltm.tm_mon
<<"/"
<<1900 + ltm.tm_year
<< " "
<< ":"
<< 1 + ltm.tm_min;
std::cout << date.str() << "\n";
Mr Tea
  • 117
  • 9

1 Answers1

1
time_t rawtime
struct tm ltm;
time(&rawtime)

localtime_s(&ltm, &rawtime)
std::ostringstream ss;
ss << std::put_time(&ltm, "%d/%m/%Y %H:%M");
std::cout << ss.str() << endl;
Mr Tea
  • 117
  • 9