> For the complete documentation index, see [llms.txt](https://til.yulrizka.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.yulrizka.com/unix/parsing-epoch-timestamp-to-date.md).

# parsing epoch timestamp to date

To get current unix timestamp we can do

```
$ date +%s
1471365644
```

But how do we parse a file which contain epoch timestamp to date?

```
$ echo 1471365644 | perl -pe 's/(\d+)/localtime($1)/e'
```

if we have it in milliseconds, we could remove the milliseconds part with

```
$ echo 1471365644000 | cut -c -10 |  perl -pe 's/(\d+)/localtime($1)/e'
Tue Aug 16 18:40:44 2016
```

Assuming your epoch seconds is 10 character. But if you have more or less, you need to do some other string processing first
