2016年9月19日 星期一

[C] Format specifier to print time(0) in C

#include <stdio.h>
#include <time.h>
#include <stdint.h>
int main(void) {
    time_t now = time(NULL);
    char s[100];
    strftime(s, sizeof s, "%F %H:%M:%S %Z", localtime(&now));
    printf("The time is now %s\n", s);
}


The time is now 2016-09-19 15:03:52 CST

Reference:

0 意見:

張貼留言