9 views

Print / Show current system date

[developer@vm-askdevops ~]$ date
Mon Mar  7 02:00:23 EST 2011

Linux print current unix time

[developer@vm-askdevops ~]$ date +%s
1299481668

Print date in YY-MM-DD format

[developer@vm-askdevops ~]$ date +'%y-%d-%m'
11-07-03

Use UPPERCASE Y for printing complete Year

[developer@vm-askdevops ~]$ date +'%Y-%d-%m'
2011-07-03

Get the current UTC Time (date -u) from a bash prompt

date -u 

Examples:

[developer@vm-askdevops ~]$ date
Mon Mar  7 02:29:53 EST 2011
[developer@vm-askdevops ~]$ date -u
Mon Mar  7 07:29:57 UTC 2011

Changing/Setting year month day YYYY MM DD only

Setting the system to a past or future DATE(Change only DATE not the time)

date -s "2010-01-01 $(date +%H:%M:%S)"

Example (Works only with root use or with sudo prefix)

[root@vm-askdevops ~]# date
Mon Mar  7 02:02:57 EST 2011
[root@vm-askdevops ~]# date -s "2010-03-07 $(date +%H:%M:%S)"
Sun Mar  7 02:03:03 EST 2010
[root@vm-askdevops ~]# date
Sun Mar  7 02:03:06 EST 2010
Aug 30, 2011 by | 9 views
DevOpsRun.com is LIVE!

Articles for DevOps Geeks
MobaXterm Customization
CHMOD Explained!
Bash history powerful tips
Ubuntu bash from Windows
..