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')
原文地址:https://www.cnblogs.com/fire909090/p/7907513.html