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

Posted on Apr 24, 2024 10:45 PM

Reply
3 replies

Apr 25, 2024 6:34 AM in response to Alexander_Ger

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).

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Using macOS Sonoma Terminal, how can I add a specific amount of days on the current date and then display it on Terminal?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.