date:- date command giving different results.
Hi All,
I am new to this Site. My task would be to suppress the hours, minutes, seconds from date which is in epoch format and the value is dynamical.
Below are my steps i have tried and i am getting different results.
For example I have used ‘20160101 01:04:01’ value and converted into epoch time.
[ ~]$ date -d "20160101 01:04:01" +%s
1451628241
I have calculated the number of days from the epoch time using the below math
[~]$ echo "1451628241/86400"|bc
16801
Then, I have multiplied with 86400 with the results.
[~]$ echo "16801*86400"|bc
1451606400
I have converted the epoch time and I would expect the output as ‘20160101 00:00:00’.But I am getting the bellow output.
[~]$ date -d @1451606400 "+%Y%m%d %H:%M:%S"
20151231 19:00:00
Please advice.
|