Created
June 11, 2016 10:08
-
-
Save blippy/c3e57066bdb1717fb7baaa6e8ab95a6c to your computer and use it in GitHub Desktop.
Format date and time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <ctime> | |
| void printtime() | |
| { | |
| std::time_t t = std::time(nullptr); | |
| char buffer[80]; | |
| strftime(buffer, 80, "%Y-%m-%d", std::localtime(&t)); | |
| std::cout << "*" << buffer << "*\n" ; // *2016-06-11* | |
| strftime(buffer, 80, "%H:%M:%S", std::localtime(&t)); | |
| std::cout << "*" << buffer << "*\n" ; // *11:05:08* | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment