我需要写一个脚本:
startdate = 2016-02-14 20:10:10
enddate = 2016-02-14 23:59:59
c= 1240 (minutes)
d=10
r = ratio(startdate - enddate) / c;
d=d*r;
如何计算开始日期和结束日期之间的差值?
答案1
要计算两次之间的秒数:
#!/bin/bash
START="2016-02-14 20:10:10"
END="2016-02-14 23:59:59"
SECS=$(echo $(date -d "$END" +%s) - $(date -d "$START" +%s) | bc)
echo $SECS