date commands

메모 2012. 1. 28. 00:48

$ date
Sat Jan 28 00:44:24 KST 2012

Getting the unixtime of now (BSD date, GNU date):
$ date +%s

1327679054

Getting the unixtime of specific moment (with LC_TIME='C', GNU date):
$ date -d 'Sat Jan 28 00:44:24 KST 2012' +%s

1327679064
$ date -d 'Sat Jan 28 00:50:01' +%s

1327679401
$ date -d 'Sat Jan 28 00:50' +%s
1327679400
$ date -d 'Sat Jan 28' +%s
1327676400

Getting the unixtime of specific moment (with LC_TIME='C', BSD date):
$ date -j 01280050.01  # format: [[[mm]dd]HH]MM[[cc]yy][.ss]
Sat Jan 28 00:50:01 KST 2012
$ date -j 01280050.01 +%s
1327679401

Getting the human readable date from unixtime: (GNU date)
$ date -d@1327679064
Sat Jan 28 00:44:24 KST 2012

Getting the human readable date from unixtime: (BSD date)
$ date -r 1327679064
Sat Jan 28 00:44:24 KST 2012

: