How to change the format of date and time with time_t?

Viewed 3349
time_t now = time(0);  
std::string h = std::string (ctime (&now));

std::cout << "\nh: " << h;

Current output that I am receiving is: Thu Sep 14 10:58:26 2017

I want the output as 2017-08-26-16-10-56

What can I do to that output?

2 Answers
Related