0

i have this date output from aws cli "2020-08-13T12:30:00+00:00".

I need to convert this string to unixtimestamp and the perform some calculation in shell script. if calculation is true then add +1day to this output in same format ex ("2020-08-14T12:30:00+00:00"), else keep the same as it is.

How to convert "2020-08-13T12:30:00+00:00" to unixtimestamp and how to add +1 day in "2020-08-13T12:30:00+00:00"

rvneo
  • 1

1 Answers1

1

How to convert "2020-08-13T12:30:00+00:00" to unixtimestamp

date --date '2020-08-13T12:30:00+00:00' +%s

how to add +1 day in "2020-08-13T12:30:00+00:00"

date --date '2020-08-13T12:30:00+00:00 + 1 day'
Léa Gris
  • 17,497
  • 4
  • 32
  • 41
  • 1
    When I answered a bash question with duplicates I got massive downvotes (even though the duplicate question was not raised when I posted). This is obviously a duplicate, so be prepared. – Ted Lyngmo Aug 12 '20 at 20:06
  • this is not working for me: ``` date --date '2020-08-13T12:30:00+00:00' +%s date: invalid date `2020-08-13T12:30:00+00:00' date --date '2020-08-13T12:30:00+00:00 + 1 day' date: invalid date `2020-08-13T12:30:00+00:00 + 1 day' ``` – rvneo Aug 12 '20 at 20:48