如何时间戳转换为猛砸日期? [英] How to convert timestamps to dates in Bash?

查看:109
本文介绍了如何时间戳转换为猛砸日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个Un​​ix时间戳转换为日期的shell命令或脚本。输入可以从第一参数或从stdin来,允许以下的使用模式

I need a shell command or script that converts a Unix timestamp to a date. The input can come either from the first parameter or from stdin, allowing for the following usage patterns:

ts2date 1267619929

echo 1267619929 | ts2date

这两个命令应该输出周三3月3日13时38分49秒2010。

Both commands should output "Wed Mar 3 13:38:49 2010".

推荐答案

在常见的Linux发行版,你可以使用更高版本:

On later versions of common Linux distributions you can use:

date -d @1267619929

这篇关于如何时间戳转换为猛砸日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆