OpenBSD Set Date and Time

last updated in Categories , ,

Q. How do I set new date and time under OpenBSD UNIX server?

A. You can set date and time using date command. OpenBSD date command uses following syntax:

date yyyymmddhhss

=> yyyy – Year
=> mm – Month
=> dd – Day
=> HHSS – Hour Second in 24 clock format

WARNING! These examples requires root level privileges (you must login as root).

Set the date to April 23, 1979, 4:27 PM, enter:
# date 197904231627
Set the time to 2:32 PM, without modifying the date, enter
# date 1432
To display current date and time, enter date command without option:
$ date

Sat Apr  3 11:06:51 IST 2008

Display the date using the specified format string:
$ date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S"

DATE: 2008-05-03
TIME: 11:07:55

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 1 comments/add one below):

1 comment

    Have a question? Post it on our forum!