Convert milliseconds timestamp to date from unix command line

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.

Leave a Comment

tech