linux date cmd(conversion between utc second and dtg)

1.查看指定时间的时间戳

查看当前时间
#date +%s

查看指定时间
#date -d 2008-01-01 +%s 
1199116800
#date -d 20080101 +%s
1199116800

2.将时间戳转换成date
#date -d '1970-01-01 UTC 1199116800 seconds'
2008年 01月 01日 星期二 00:00:00 CST

#export LANG=en
#date -d '19700101 UTC 1199116800 seconds' 
Tue Jan  1 00:00:00 CST 2008

3.
date -d @1416387827    #same as date -d '1970-01-01 UTC 1416387827 seconds'

aspirs@ubuntu1204:~$ date -d @1416387827
Wed Nov 19 17:03:47 CST 2014
aspirs@ubuntu1204:~$ date -d '1970-01-01 UTC 1416387827 seconds'
Wed Nov 19 17:03:47 CST 2014

from http://haoningabc.iteye.com/blog/1151388

原文地址:https://www.cnblogs.com/aspirs/p/7082395.html