Home > Enterprise >  remove millisecond from echo time bash
remove millisecond from echo time bash

Time:01-20

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

  1. So i used 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.

CodePudding user response:

You can divide by 1000 and convert to timestamp.

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

CodePudding user response:

Strip milliseconds with bash:

x="1633036680022"
date -d "@${x:0:10}"
  •  Tags:  
  • Related