0

I have a script I am trying to write where it requires that I am able to do math with time. For example I want to subtract two hours from Feb 12 01:25 so the result should be Feb 11 23:25. However bash does not have built in types so it does not make this an easy task as it would be in any other programming language.

Cyrus
  • 84,225
  • 14
  • 89
  • 153
A. Epstein
  • 11
  • 1
  • https://askubuntu.com/questions/408775/add-seconds-to-a-given-date-in-bash – Barmar May 06 '17 at 23:37
  • http://stackoverflow.com/questions/21208473/calculating-time-adding-minutes-bash – Barmar May 06 '17 at 23:38
  • @Barmar I have found questions and answers like the one you posted but they don't work for me they just echo what would happen. Ex i wrote `newtime= date -d "16:00 410 minutes" +'%H:%M' echo $newtime` and the console output `usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]` – A. Epstein May 06 '17 at 23:51
  • 1
    See http://stackoverflow.com/questions/9804966/date-command-does-not-follow-linux-specifications-mac-os-x-lion – Barmar May 06 '17 at 23:53
  • 1
    @Barmar Thanks so much that was the answer i needed! – A. Epstein May 07 '17 at 00:02

0 Answers0