I want to set date from a seconds since epoch value, for instance I want to set date with input value 1452053571
.
I read through date -help
but not found anything.
Is there any parameters to do it?
I want to set date from a seconds since epoch value, for instance I want to set date with input value 1452053571
.
I read through date -help
but not found anything.
Is there any parameters to do it?
With GNU date, you can use the same date string format for both -d
and -s
options.
To convert from seconds since epoch to human readable format:
date -d '@2147483647'
To set it:
date -s '@2147483647'
With *BSD date
:
# Convert seconds since epoch
$ date -r 2147483647
Tue Jan 19 03:14:07 UTC 2038
# Set date by seconds since epoch
$ date "$(date -r 2147483647 +'%y%m%d%H%M.%S')"
Tue Jan 19 03:14:07 UTC 2038
date --date='@2147483647'
– cuonglm Jan 06 '16 at 04:23How to set
? – Rong Nguyen Jan 06 '16 at 04:25sudo date -s "$(date --date='@2147483647')"
:) – Rong Nguyen Jan 06 '16 at 04:28date -s '@2147483647'
. Please reword+reformat your question to make it more clear. – cuonglm Jan 06 '16 at 04:37