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

来源:互联网 发布:第一次在淘宝购物流程 编辑:程序博客网 时间:2024/05/18 00:06

#!/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')


0 0
原创粉丝点击