I want to convert epoch like "1444039517190" to yyyy-mm-ddThh:mm:ss using linux?
I have tried using the following script but it gives the wrong output:
echo 1444039517190 | awk '{ print strftime("%Y-%m-%d %H:%M:%S",$1) }'
Output:
47729-10-16 09:06:30
Your timestamp is not in seconds; try:
echo 1444039517190 | awk '{ print strftime("%Y-%m-%d %H:%M:%S",$1/1000) }'
Or if you don't mind losing precision:
date --date=@$((1444039517190 / 1000)) +%Y-%m-%d\ %H:%M:%S
And check if your version of strftime(3)
support the shorter format %F %T
instead of %Y-%m-%d %H:%M:%S
.