S M
S M

Reputation: 101

Covert string to a date bash

I am trying to convert ProcessedTime": 1545166011.794351 to a date using date function in bash script, what is the best way to convert it ?

Upvotes: 0

Views: 45

Answers (2)

Cyrus
Cyrus

Reputation: 88563

With GNU awk:

echo 154166011.794351 | awk '{print strftime("%Y-%m-%d %H:%M:%S",$0)}'

Output:

1974-11-20 08:53:31

Source: https://unix.stackexchange.com/a/168317/74329

Upvotes: 1

jasonmclose
jasonmclose

Reputation: 1695

date -d @154166011.794351

Date command should work fine.

Upvotes: 3

Related Questions