Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
#include
#include
using namespace std; int main() { time_t timestamp; char output[50]; struct tm * datetime; time(×tamp); datetime = localtime(×tamp); strftime(output, 50, "%B %e, %Y", datetime); cout << output << "\n"; strftime(output, 50, "%I:%M:%S %p", datetime); cout << output << "\n"; strftime(output, 50, "%D", datetime); cout << output << "\n"; strftime(output, 50, "%c", datetime); cout << output << "\n"; return 0; } // Note: This example displays the server's local time, which may differ from your local time.
Formatted Date and Time