UNIX编程

发布于 2024-09-11 02:50:29 字数 327 浏览 2 评论 0原文

您好,我想将 UNIX 日期转换为正常日期 (YYYY-MM-DD),

22222,0,0,0,14387
33333,0,0,0,14170
44444,0,0,0,14244
55555,0,0,0,14190
66666,0,0,0,14528
77777,0,0,0,14200
88888,0,0,0,0
99999,0,0,0,0

UNIX 日期

这里第 5 列代表我想要转换的

22222,0,0,0,2009-05-23

,类似的剩余行

任何人都可以帮助我

Hi i want to convert UNIX date to normal date (YYYY-MM-DD)

22222,0,0,0,14387
33333,0,0,0,14170
44444,0,0,0,14244
55555,0,0,0,14190
66666,0,0,0,14528
77777,0,0,0,14200
88888,0,0,0,0
99999,0,0,0,0

here 5th column represents UNIX date

i want to convert into

22222,0,0,0,2009-05-23

and similarly remaining rows

can any body help me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江城子 2024-09-18 02:50:29

一个简单的 awk 脚本应该可以做到这一点

awk -F, 'BEGIN{OFS=","} { print $1,$2,$3,$4,strftime("%Y-%m-%d",$5) }' myFile.txt

干杯。

编辑:
您没有使用 unix 时间戳,但我检查了您的数据,看来您正在使用自纪元以来的天数,所以这里是:

awk -F, 'BEGIN{OFS=","} { print $1,$2,$3,$4,strftime("%Y-%m-%d",$5*86400) }' myFile.txt

A simple awk script ought to do it

awk -F, 'BEGIN{OFS=","} { print $1,$2,$3,$4,strftime("%Y-%m-%d",$5) }' myFile.txt

Cheers.

EDIT:
You're not using unix timestamps, but I checked your data, and it appears you're using days since the epoch, so here goes:

awk -F, 'BEGIN{OFS=","} { print $1,$2,$3,$4,strftime("%Y-%m-%d",$5*86400) }' myFile.txt
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文