Monday, March 30, 2009

Changing Date and Time in Unix BSD

This post is as much for me as anyone else, I always forget this simple command for changing the system date or system time in BSD Unix.

Simply (as root) type 'date' then hit enter
This will spit back the current date and time

If you want to change it, type 'date yyMMddhhmm' then hit enter
  • yy with 2 digit year code
  • MM with 2 digit month code
  • dd with 2 digit day code (date)
  • hh with two digits for hours (Unix uses 24 hour clock)
  • mm with two digits for minutes
In this example 'date 0903300935' you will get the time and date of March 30th, 2009 at 9:35AM

Remember that BSD Unix is using a 24 hour (military) clock. So if you need something in the afternoon, say 3:35pm, you would use 'date 0903301535' then hit enter. This would render the date and time as March 30th, 2009 at 3:35PM

That is how you change the time in BSD Unix.

No comments: