Formatting Unix timestamp with ctime in c

后端 未结 2 1006
时光说笑
时光说笑 2021-01-05 18:12

I\'m trying to format a 10-digit Unix time stamp (currently a string) using ctime.

However, ctime() expects a parameter of type time_t, not a string.

What m

2条回答
  •  萌比男神i
    2021-01-05 18:46

    You're saying you have something like 1346426869 as a string and want it to be a time_t?

    time_t raw_time = atoi("1346426869");
    printf("current time is %s",ctime(&raw_time));
    
    > current time is Fri Aug 31 11:27:49 2012
    

提交回复
热议问题