date add command Terminal: How to add time using `date`? (illegal time format)
I'm trying to add minutes to the current time using date
. This works for adding 5 minutes:
$ date -v "+5M"
But if I try using -v
with a formatting argument, it fails and prints the help menu:
$ date "+%r" -v "+5M"
date: illegal time format
Is it possible to use the %r
formatting with -v
?
Solution 1:
Put "+%r"
after the "+5M"
:
$ date -v "+5M" "+%r"
02:25:14 PM