-2

I have a number, lets say it is 20160823130001 which stands for 2016 august 23rd 1300 hrs 1 second. But sometimes the date stamp will be 20160823125959.

From that number I need to add or subtract 10 mins and I cannot figure out how to do it in bash. This would be easy if it was 1330 hrs but since it is 1300 it needs to end up as 1240 and 1310. I could do some strange checks to subtract or add such as if 125959 then add 51 elseif 130000 add 10 but this seems clunky. How can I make this happen without strange checks using bash?

Thank you for any pointers.

codeforester
  • 39,467
  • 16
  • 112
  • 140
Cc Dd
  • 159
  • 1
  • 6
  • 1
    You will find your answer here: http://stackoverflow.com/questions/4197606/how-to-convert-yyyymmddhhmmss-to-a-date-readable-by-date – codeforester Jan 11 '17 at 02:57

1 Answers1

0

Convert the string into a date first and then do the manipulation. Links on how to do that are in the comments section

Karan Shah
  • 1,304
  • 11
  • 15