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?

2

1 Answer 1

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
1
  • 2
    Great self-answered question! May 10, 2019 at 20:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .