In the Apple's date manpage ($ man date
) it's written:
Finally the command:
`date -j -f "%a %b %d %T %Z %Y" "`date`" "+%s"
can be used to parse the output from date and express it in Epoch time.
But when I'm executing this command ($ date -j -f "%a %b %d %T %Z %Y" "`date`" "+%s"
) in a new Basic Shell from Terminal I get:
Failed conversion of ``Ven 12 mai 2017 08:22:03 CEST'' using format ``%a %b %d %T %Z %Y''
date: illegal time format
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
[-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
Why? Does it same for you? How can I correct it?
NB: I'm on macOS Sierra 10.12.4 with French settings and Paris local time (UTC +02:00)
Best Answer
You are using the following date format:
So the correct command is