Using macOS Sonoma Terminal, how can I add a specific amount of days on the current date and then display it on Terminal?
Thank you.
MacBook Air, macOS 14.4
Thank you.
MacBook Air, macOS 14.4
This is the correct version of that command:
date -u -v +30d
You can display a specific date. It's important to include the -j option otherwise the command will actually set the system date to what you specify, rather than simply display the result. The format is:
date -j mmddHHMMccyy.SS
So this:
date -j 042514192024.15
prints this:
Thu 25 Apr 2024 14:19:15 BST
You can also use the -v option to adjust the date specified:
date -j -v +30d 042514192024.15
prints this:
Sat 25 May 2024 14:19:15 BST
It's documented on the man page (use the command "man date"). There is information there about changing the input format of the date from the default to something else (use the -f option).
Thank you. Do you know by any chance how to do the same for a specific date as input?
Using macOS Sonoma Terminal, how can I add a specific amount of days on the current date and then display it on Terminal?