0

I want to convert epoch like "26/11/05 06:00:01,057000000" to yyyy-mm-ddThh:mm:ss using linux?

I have tried using the following script with no luck:

echo 26/11/05 06:00:01,057000000 | awk '{ print strftime("%Y-%m-%d %H:%M:%S",$1) }'

Output:

1970-01-01 01:00:26
Kelv
  • 49
  • 1
  • 11

1 Answers1

0
#!/usr/bin/env python
import sys
from datetime import datetime

time_string = ' '.join(sys.argv[1:])
dt = datetime.strptime(time_string, '%d/%m/%y %H:%M:%S,%f000')
print(dt.isoformat())

Example (save the above code to convert-time-format and run
chmod +x convert-time-format):

$ ./convert-time-format 26/11/05 06:00:01,057000000
2005-11-26T06:00:01.057000
jfs
  • 399,953
  • 195
  • 994
  • 1,670