How come date is converting to wrong time?
result=$(ls /path/to/file/File.*) #/path/to/file/File.1361234760790 currentIndexTime=${result##*.} echo "$currentIndexTime" #1361234760790 date -d@"$currentIndexTime" #Tue 24 Oct 45105 10:53:10 PM GMT
Convert from epoch to human-readable datemyString := DateTimeToStr(UnixToDateTime(Epoch)); Where Epoch is a signed integer. Replace 1526357743 with epoch. =(A1 / 86400) + 25569 Format the result cell for date/time, the result will be in GMT time (A1 is the cell with the epoch number).
You can take an epoch time divided by 86400 (seconds in a day) floored and add 719163 (the days up to the year 1970) to pass to it. Awesome, this is as manual as it gets.
Use the build-in date command and instruct it to output the number of seconds since 1970-01-01 00:00:00 UTC. You can do this by passing a format string as parameter to the date command. The format string for UNIX epoch time is '%s'. To convert a specific date and time into UNIX epoch time, use the -d parameter.
This particular timestamp is in milliseconds since the epoch, not the standard seconds since the epoch. Divide by 1000:
$ date -d @1361234760.790 Mon Feb 18 17:46:00 MST 2013
For Mac OS X, it's date -r <timestamp_in_seconds_with_no_fractions>
$ date -r 1553024528 Tue Mar 19 12:42:08 PDT 2019
or
$ date -r `expr 1553024527882 / 1000` Tue Mar 19 12:42:07 PDT 2019
or
$ date -r $((1553024527882/1000)) Tue Mar 19 12:42:07 PDT 2019
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With