问题描述
我有一个ISO格式的日期YYYY-MM-DDTHH:SS(例如2014-02-14T12:30).我想将其转换为自epoch以来的秒数,仅使用linux bash中的date命令.
所有日期均指UTC语言环境.
我知道这个问题很容易重复...关于将日期从一种格式转换为另一种格式有数十亿个问题,但我找不到自己的特殊情况
谢谢...
对于GNU日期,请使用-d
指定要解析的日期,并使用%s
$ date -d"2014-02-14T12:30" +%s
1392381000
I have a date in the ISO format YYYY-MM-DDTHH:SS (e.g. 2014-02-14T12:30). I'd like to convert it in seconds since epoch using only the date command in linux bash.
All the dates refer to UTC locale.
I know that this question is easily eligible for duplicate... there are billions of questions about converting dates from one format to another but I can't find my particular scenario
thank you...
With GNU date, specify the date to parse with -d
and seconds since epoch with %s
$ date -d"2014-02-14T12:30" +%s
1392381000
这篇关于将ISO日期转换为linux bash中的纪元以来的秒数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!