$ date +"%Y-%m-%d %H:%M:%S"
2014-11-21 23:59:37
$ date +%s
1361542433
$ date -d "2008-01-01 00:00:00" +%s
1199116800
$ date -d 2008-01-01 +%s
1199116800
$ date -d 20080101 +%s
1199116800
例外: 有一种场景date格式是连续的(没找到date命令怎么转换成unix)
$ echo 20080101010101 | awk '{print substr($0,1,4)"-"substr($0,5,2)"-"substr($0,7,2)" "substr($0,9,2)":"substr($0,11,2)":"substr($0,13,2) }'
2008-01-01 01:01:01
$ date -d "2008-01-01 01:01:01" +%s
1199120461
$ date -d @1199116800 +"%Y-%m-%d %H:%M:%S"
2008-00-01 00:00:00
date -d @`date +%s` +"%Y-%m-%d %H:%M:%S"
等价于
date +"%Y-%m-%d %H:%M:%S"
$ date -d "2008-01-01 00:00:00" +%Y-%M-%d" "%H:%M:%S
2008-00-01 00:00:00
$ date -d "2008-01-01 00:00:00" +"%Y%M%d %H%M%S"
20080001 000000
$ date -d "2008-01-01 00:00:00" +"%Y/%M/%d %H:%M:%S"
2008/00/01 00:00:00
time.mktime(datetime.datetime.now().timetuple())
datetime.datetime.fromtimestamp(int("1284101485")).strftime('%Y-%m-%d %H:%M:%S')
time.mktime(datetime.datetime.strptime(time,"%Y-%m-%d %H:%M:%S").timetuple())