帝王谷资源网 Design By www.wdxyy.com

复制代码 代码如下:
#!/bin/sh
# 获取所在季度的第一天,到昨天的日期间隔
# link:www.jb51.net
# date:2013/2/28

day=`date -d "1 days ago " "+%Y%m%d"`;
year=`expr substr ${day} 1 4`;
month=`expr substr ${day} 5 2`;
s_date=$year"0101"
if [ "$month" == "01" ] || [ "$month" == "02" ] || [ "$month" == "03" ];then
   s_date=$year"0101"
elif [ "$month" == "04" ] || [ "$month" == "05" ] || [ "$month" == "06" ];then
   s_date=$year"0401"
elif [ "$month" == "07" ] || [ "$month" == "08" ] || [ "$month" == "09" ];then
   s_date=$year"0701"
elif [ "$month" == "10" ] || [ "$month" == "11" ] || [ "$month" == "12" ];then
   s_date=$year"1001"
fi
e_date=$day
sys_s_data=`date -d "$s_date" +%s`
sys_e_data=`date -d "$e_date" +%s`
interval=`expr $sys_e_data - $sys_s_data`
daycount=`expr $interval / 3600 / 24 + 1`

echo $daycount

标签:
两个日期,间隔时间

帝王谷资源网 Design By www.wdxyy.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
帝王谷资源网 Design By www.wdxyy.com