shell日期与时间戳转换的例子
时间:2014-07-28 13:04 来源:linux.it.net.cn 作者:it
shell中将日期转换为时间戳的方法,date命令的参数与用法
shell中获取时间戳的方式:
date -d “$currentTime” +%s
将一个日期转为时间戳,请参考如下方法:
1、得到当前时间
currentTime=`date “+%Y-%m-%d %H:%M:%S”`
2、将日期转为时间戳
currentTimeStamp=`date -d “$currentTime” +%s`
echo $currentTimeStamp
(责任编辑:IT)
shell中将日期转换为时间戳的方法,date命令的参数与用法
shell中获取时间戳的方式:
date -d “$currentTime” +%s
将一个日期转为时间戳,请参考如下方法:
1、得到当前时间
currentTime=`date “+%Y-%m-%d %H:%M:%S”`
2、将日期转为时间戳
currentTimeStamp=`date -d “$currentTime” +%s`
(责任编辑:IT)echo $currentTimeStamp |