Posts Tagged ‘awk’

在shell中将unix时间戳转换为系统时间

用date +%s可以得到UNIX的时间戳,
如date +%s
1273460780
date转化为系统时间
date -d ’1970-01-01 UTC 1273460780 seconds’ +”%Y-%m-%d %T %z”
2010-05-10 11:06:20 +0800  (时间格式自行设计)
也可以用awk
awk ‘BEGIN{x=strftime(“%b %d %T CST %Y”, “1273460780″);print x}’
May 10 11:06:20 CST 2010
UNIX时间戳 就是1970-01-01到某个时间的总秒数。
可以自己编个程序算一算

Read the rest of this entry »