OM_datetime

commands: date/zdump/time/touch/at/batch/cal/sleep/usleep/hwclock/clock#date -u # UTC time#date "+%j" # number of days since the year's beginning#date "+%s" # Unix timestamp,number of seconds since 01/01/1970#date -d @1398834785 # Unix timestamp trans to date#zdump EST # Time zone dump:#touch file_exists # >> newfile or >> newfile#touch * # 统一更新当前目录下所有的文件和目录的时间戳#cal 2014 #显示2014的日历............>>>>> 用时间创建临时文件prefix=tempsuffix=$(date +%s) # Unix时间戳filename=$prefix.$suffix............>>>>> 前一段时间SixDaysAgo=$(date --date='6 days ago')OneMonthAgo=$(date --date='1 month ago')............>>>>> 时间差计算MPHR=60 # Minutes per hour.MPD=24 # Hours per day.dt=`date`CURRENT=$(date -u -d "$dt" '+%F %T.%N %Z')TARGET=$(date -u -d'2014-06-15 12:30:00' '+%F %T.%N %Z')# %F = full date, %T = %H:%M:%S, %N = nanoseconds, %Z = time zone.echo -e "date now:\t$CURRENT \nMy target:\t$TARGET\n"# count seconds between two timesdiff=$(( $(date -u -d"$TARGET" +%s) - $(date -u -d"$CURRENT" +%s)))DAYS=$(( $diff / $MPHR / $MPHR / $MPD ))HOURS=$(( $diff / $MPHR / $MPHR ))MINUTES=$(( $diff / $MPHR ))printf '%s days,%s hours,' "$DAYS" "$HOURS"printf '%s minutes,and %s seconds. ' "$MINUTES" "$diff"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值