In linux, date
can help me to print the current time. If want to print the current time + 1 hour, what option should I give?
Using at. From the interactive shell, you can enter the command you want to run at that time. If you want to run multiple commands, press enter after each command and type the command on the new at> prompt. Once you're done entering commands, press Ctrl-D on an empty at> prompt to exit the interactive shell.
date command is used to display the system date and time. date command is also used to set date and time of the system. By default the date command displays the date in the time zone on which unix/linux operating system is configured. You must be the super-user (root) to change the date and time.
Just use -d
(or --date
) to do some math with the dates:
date -d '+1 hour' '+%F %T' # ^^^^^^^^^^^^
For example:
$ date '+%F %T' 2013-04-22 10:57:24 $ date -d '+1 hour' '+%F %T' 2013-04-22 11:57:24 # ^
Warning, the above only works on Linux, not on Mac OS.
On Mac OS, the equivalent command is
date -v+1H
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With