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?
Asked
Active
Viewed 311 times
-1
-
1Possible duplicate of [Convert string to date in bash](https://stackoverflow.com/questions/11144408/convert-string-to-date-in-bash) – abcalphabet Jan 25 '19 at 12:30
-
this is not duplicate of what you suggested @abcalphabet – Derviş Kayımbaşıoğlu Jan 25 '19 at 12:35
-
1Possible duplicate of [Parse Date in Bash](https://stackoverflow.com/questions/1842634/parse-date-in-bash) – nullPointer Jan 25 '19 at 12:37
1 Answers
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