strftime格式化输出时间

 1 #include<stdio.h>
 2 #include<time.h>
 3  
 4 int main(int argc, char *argv[])
 5 {
 6    time_t rawtime;
 7    struct tm *info;
 8    char buffer[80];
 9    time( &rawtime );
10    info = localtime( &rawtime );
11    strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", info);
12    printf("日期 & 时间 : |%s|
", buffer );
13   
14    return(0);
15 }
//时间:输出
//日期 & 时间 : |2021-08-06 08:05:07|
点滴珍贵,重在积累,愿时光慢一点,再慢一点。
原文地址:https://www.cnblogs.com/timemachine213/p/15106895.html