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"
OM_datetime
最新推荐文章于 2024-10-14 16:47:18 发布