Monday, August 08, 2011

Setting date and time on Linux/Unix

date mmddhhmi

where:
mm = month
dd = day of month
hh = hour
mi = minute

Example for today date:
sudo date 08081530

Another way, set new data to 8 August 2011 15:30:00, type the following command as root user:
# date -s "8 AUG 2011 15:30:00"

OR
# date --set="8 AUG 2011 15:30:00"

You can also simplify format using following syntax:
# date +%Y%m%d -s "20110808"

Linux Set Time
To set time use the following syntax:
# date +%T -s "15:30:00"