shell脚本将任何日期转换为毫秒

shell脚本将任何日期转换为毫秒,shell,Shell,我想用毫秒计算这个时间 01/Mar/2012:09:08:00 time=01/Mar/2012:09:08:00 newDate=date --set="$time"; 我认为执行以下操作将存储新日期,然后我可以将日期转换为毫秒 01/Mar/2012:09:08:00 time=01/Mar/2012:09:08:00 newDate=date --set="$time"; 我需要做什么才能让它工作?使用Timer()方法获取时间,然后将时间放入fo

我想用毫秒计算这个时间

01/Mar/2012:09:08:00
    time=01/Mar/2012:09:08:00
    newDate=date --set="$time";
我认为执行以下操作将存储新日期,然后我可以将日期转换为毫秒

01/Mar/2012:09:08:00
    time=01/Mar/2012:09:08:00
    newDate=date --set="$time";
我需要做什么才能让它工作?

使用
Timer()
方法获取时间,然后将时间放入
formatnumber()
方法中,如下所示

FormatNumber(Timer(), 2)

您应该将
'01/Mar/2012:09:08:00'
转换为有效的日期字符串
'01 Mar/2012 09:08:00'

$ time=01/Mar/2012:09:08:00
$ time="${time//// }"
$ time="${time/:/ }"
$ newDate=`date -d "$time" +%s000`
$ echo $newDate
1330564080000

我有最简单的方法将日期转换为毫秒:

echo $(date +'%s')

追加
000
毫秒:-)问题是关于Unix shell的;
Timer()
FormatNumber()
方法不存在。@KeithThompson此解决方案在VB脚本或shell脚本中可用于此目的。所谓“以毫秒为单位的时间”,是指自Unix纪元(1970-01-01)以来的毫秒吗?请注意,
01/Mar/2012:09:08:00
不是
date
命令可以识别的格式。您能否以更传统的格式获取时间,如
“2012年3月1日09:08:00”
?请编辑您的帖子,以包含所需输出的示例。祝你好运