Tuesday, May 7, 2013

Date and Time in Linux


Set Date

Use the following syntax to set new data and time:
date --set="STRING"

set new data to 23 Jan 2012 2:12:15

date --set="Tue Jan 23 2:12:15 EDT 2012"

You can format as belwo:

date +%Y%m%d -s "20120910"


Set Time

Use the following syntax to set time:

# date +%T -s "11:10:05"

11Hour (hh)

10: Minute (mm)

05: Second (ss)

Use %p locale’s equivalent of either AM or PM, enter:

# date +%T%p -s "2:12:30AM"

# date +%T%p -s "11:12:30PM"

No comments:

Post a Comment