Issue
I know about
date -d @<timestamp in seconds>
and
awk '{print strftime("%c", <timestamp in seconds>)}'
but what if I have milliseconds. Is there trivial way to do this without dropping the final three characters of the millisecond-timestamp (not that dropping characters is difficult, but I would think there'd be a one-step way for such a straightforward task)?
Solution
Instead of dropping characters, you could divide by 1000:
awk '{print strftime("%c", ( <timestamp in milliseconds> + 500 ) / 1000 )}'
Or:
date -d @$( echo "(MilliSecondTimeStamp + 500) / 1000" | bc)
Or (MacOS):
gdate -d @$( echo "(MilliSecondTimeStamp + 500) / 1000" | bc)
Edit: Adjusted for the quotients instead of division. Edit2: Thx zeekvfu, fixed.
Answered By - joepd Answer Checked By - Terry (WPSolving Volunteer)