Search code examples
bashtimetimestampepochhuman-readable

remove millisecond from echo time bash


1633036680022 , This is epoch result i got from elasticsearch. if i tried to convert this epcho to human-readable date,

  1. So i used epochconverter enter image description here
  2. And i used bash command to convert this in my terminal,
$ date -d @1633036680022

Tuesday 15 November 53718 05:30:22 PM IST

This output from terminal say the Year 53718, because the epoch '1633036680022' is in milliseconds.

All i want is ,epoch in seconds.


Solution

  • You can divide by 1000 and convert to timestamp.

    date -d @"$(echo "1633036680022/1000" | bc)"