http://eleaction01.spaces.eepw.com.cn/articles/article/item/208277
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
void utc_to_local2(char *dst ,const char *stamp)
{
//char buf[512];
long t = atoi(stamp);
struct tm x;
time_t cstamp = t;
x = *localtime(&cstamp);
sprintf(dst, "%d/%d/%d %d:%d:%d",x.tm_year+1900,x.tm_mon + 1, x.tm_mday, x.tm_hour, x.tm_min, x.tm_sec);
//printf("%s\n", dst);
}
/*获取系统时间戳*/
void get_stamp(void)
{
struct timeval t;
gettimeofday(&t,NULL);
printf("sec:%ld\n",t.tv_sec); // sec
printf("sec:%ld\n",t.tv_sec*1000+t.tv_usec); //msec
}
int main(void) {
char buf[64];
utc_to_local2(buf,"1677045422");
printf("%s\n", buf);
get_stamp();
return 0;
}