Formatting Unix timestamp with ctime in c

后端 未结 2 943
时光说笑
时光说笑 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条回答
  •  抹茶落季
    2021-01-05 18:21

    The time_t type is just an integer. It is the number of seconds since the Epoch. You'll need to parse the string first.

    Start here:

    http://www.gnu.org/software/libc/manual/html_node/General-Time-String-Parsing.html#General-Time-String-Parsing

    and work your way forward from there.

提交回复
热议问题