unix时间戳转换公式_unix时间戳在线转换工具使用

unix时间戳转换公式_unix时间戳在线转换工具使用,第1张

unix时间转换公式_unix时间戳在线转换工具使用 日常工作中经常需要查看当前时间戳或者转换时间戳到日期,为此写了一个小工具,方便转换,分享给小伙伴,喜欢的请关注并点赞!#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <time.h>int main(int argc,char *argv[]) { time_t newtime; if (2 == argc) { newtime = strtol(argv[1],NULL,10); char szBuff[30]; strftime(szBuff, sizeof(szBuff), "%Y/%m/%d %X", localtime(&newtime)); printf("%sn",szBuff); } else { time(&newtime); printf("%ldn",newtime); } exit(0);}编译gcc -Wall -o showtime showtime.c使用chmod +x showtimecp showtime /usr/local/bin/showtimeshowtime 1624964738

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/649472.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-17
下一篇 2022-04-17

发表评论

登录后才能评论

评论列表(0条)

保存