-1

I have date in string variable in this format: yyyymmddThhmmss.sss. For example: 20171115T102601.259 How can i convert this string to date in Bash?

Chivolta
  • 11
  • 3

1 Answers1

0

Check this

dt=$(sed -E "s/([0-9]{8})T([0-9]{2})([0-9]{2})([0-9]{2})/\1 \2:\3:\4/" <<< "20171115T102601.259")

date  -d "$dt"
Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72