Mega Code Archive

 
Categories / C++ Tutorial / Data Types
 

Show a custom time and date string

#include <iostream> #include <ctime> using namespace std; int main() {   char str[64];   // Get the current system time.   time_t t = time(NULL);   // Show a custom time and date string.   strftime(str, 64, "%A, %B %d %Y %I:%M %p", localtime(&t));   cout << "Custom format: " << str << endl;   return 0; }