开发者

Converting a date formated as DD/MM/YYYY to seconds spent from 01/01/1970?

开发者 https://www.devze.com 2022-12-29 19:11 出处:网络
Following command converts date formated as MM/DD/YYYY to seconds. date -d \"01/21/2014\" +%s How can I conve开发者_开发知识库rt DD/MM/YYYY formated date to seconds?

Following command converts date formated as MM/DD/YYYY to seconds.

date -d "01/21/2014" +%s

How can I conve开发者_开发知识库rt DD/MM/YYYY formated date to seconds?

Thanks


The correct format as the following

date '+%m/%d/%Y'


Assuming you want epoch seconds, with perl:

perl -MTime::Local -we \
'do {@a = split(m|/|,$_); $a[1]--; print timegm(0,0,0,@a)."\n"} for @ARGV' \
01/11/2010

Also note that you specify DD/MM/YYYY as format but give an example of MM/DD/YYYY.


date -j -f "%d/%m/%Y" "DD/MM/YYYY" "+%s"
0

精彩评论

暂无评论...
验证码 换一张
取 消