7

I’m trying to keep the high (millisecond) precision of my time, shown in my $TIME variable.

I’m confused by the output I get, because I try to add 5 minutes, but it looks like it's subtracting 8 hours and 59 minutes?

TIME="23:01:05.001"
echo $TIME
date -d "$TIME + 5 min" +"%H:%M:%S.%3N"

23:01:05.001
14:02:05.001

But my desired output is:

23:06:05.001

How can I use date with my $TIME variable and just add five minutes to it?

5

Seemingly in conflict with other use I've been able to find of date -d It turns out the way to add minutes that works for me is:

TIME="23:01:05.001"
echo $TIME
date -d "$TIME 5min" +"%H:%M:%S.%3N"

23:01:05.001
23:06:05.001
| improve this answer | |
  • 2
    Great self-answered question! – JakeGould May 10 '19 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.