shell下获取上一个月,星期时间和时间戳的范围

 

 

#!/bin/bash

#一月前

historyTime=$(date "+%Y-%m-%d %H" -d  '1 month ago')

echo ${historyTime}
historyTimeStamp=$(date -d "$historyTime" +%s)

echo ${historyTimeStamp}

 

#一周前

$(date "+%Y-%m-%d %H" -d  '7 day ago')

 

 

 
#本月一月一日
date_this_month=`date +%Y%m01`

 

 

#一天前

date_today=`date -d '1 day ago' +%Y%m%d`

 

#一小时前

 

 
$(date "+%Y-%m-%d %H" -d  '-1 hours')
posted @ 2017-11-28 08:51  fire909090  阅读(1730)  评论(0编辑  收藏  举报