Home > Article > Backend Development > Write a C program that uses time.h library functions
How to display the current date and time in ISO standard format using C language?
Current Date and Time will take the entered time and attempt to print the system time and date in ISO format.
For example, Monday, December 15, 2020 at 10:50.
Built - The function we are using in this program is -
Time() - Returns the current time.
Strftime() − Convert time to string form, this function is included in time.h.
Live demonstration
#include<stdio.h> #include<time.h> int main(){ time_t current = time(NULL); char datetime[20]; strftime(datetime,sizeof(datetime),"%a,%d%b%y %H:%M",localtime(¤t)); puts(datetime); return 0; }
Thu,31 Dec 20 22:41
The above is the detailed content of Write a C program that uses time.h library functions. For more information, please follow other related articles on the PHP Chinese website!