Converting a date formated as DD/MM/YYYY to seconds spent from 01/01/1970?
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"
精彩评论