如何bash脚本格式的UNIX时间字符串 [英] how to bash script format unix time to string
本文介绍了如何bash脚本格式的UNIX时间字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要字符串转换为UNIX时间你做的:
to convert string to unix time you do:
date --date "2012-02-13" +%s
我怎么做相反?格式unixtime字符串?
how do I do the opposite? format unixtime to string?
推荐答案
您可以使用日期--date @datetime
:
[foo@bar ~]$date --date "2012-02-13" +%s
1329055200
[foo@bar ~]$date --date @1329055200
Mon Feb 13 00:00:00 EST 2012
[foo@bar ~]$date --date @1329055200 +"%Y-%m-%d"
2012-02-13
我不知道那里的'@xxxx虽然是记录!
I'm not sure where the '@xxxx' is documented though!
这篇关于如何bash脚本格式的UNIX时间字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文