date

From Initq

Jump to: navigation, search

Display the current time in the given FORMAT, or set the system date.

date [OPTION]... [+FORMAT] The + sign is only used for format.

The format is [MMDDhhmmYYYY.ss]


Example

date 102020122009.00

Contents

Universal Time

qais@qais:~$ date -u
Tue Nov  3 18:29:05 UTC 2009

AM/PM format

qais@qais:~$ date +%T%p
12:40:26PM
[root@initq test]# date '+%y'
10
[root@initq test]# date '+%Y'
2010
[root@initq test]# date '+%Y%m'
201003
[root@initq test]# date '+%Y%m%d'
20100331
[root@initq test]# date '+%Y%m%d%h'
20100331Mar
[root@initq test]# date '+%Y%m%d%H'
2010033120
[root@initq test]# date '+%Y%m%d%H%d'
201003312031
[root@initq test]# date '+%Y%m%d%H%d%s'
2010033120311270084280
[root@initq test]# date '+%Y%m%d%H%d%S'
20100331203125

Show old dates

root@initq:~# date --date='20 seconds ago'
Sat Jul  9 01:20:00 CDT 2011
root@initq:~# date --date='1 day ago'
Fri Jul  8 01:20:29 CDT 2011
root@initq:~# date --date='1 month 2 hours ago'
Mon Aug  8 23:21:07 CDT 2011
root@initq:~# date --date='10 month 2 hours ago 2 days ago'
Sun May  6 23:21:32 CDT 2012

Show future dates

root@initq:~# date --date='20 years 50 days'
Thu Aug 28 01:26:55 CDT 2031
root@initq:~# date --date='1000 years 50 days'
Wed Aug 28 01:27:32 CDT 3011
root@initq:~# date --date='this wednesday'
Wed Jul 13 00:00:00 CDT 2011
Personal tools