parsing epoch timestamp to date
To get current unix timestamp we can do
1
$ date +%s
2
1471365644
Copied!
But how do we parse a file which contain epoch timestamp to date?
1
$ echo 1471365644 | perl -pe 's/(\d+)/localtime($1)/e'
Copied!
if we have it in milliseconds, we could remove the milliseconds part with
1
$ echo 1471365644000 | cut -c -10 | perl -pe 's/(\d+)/localtime($1)/e'
2
Tue Aug 16 18:40:44 2016
Copied!
Assuming your epoch seconds is 10 character. But if you have more or less, you need to do some other string processing first
Last modified 1mo ago
Copy link