#!/usr/bin/ksh # AUTHOR: Xin23 # Version: Beta 0.1 # Date: 2014-09-05 Get_Days_From_1970(){ BEGINYEAR=1970 ENDYEAR=$(date +%Y) YEARNUM=$(($ENDYEAR-$BEGINYEAR)) LYEARNUM=$(($YEARNUM/4)) RNUM=${LYEARNUM%.*} DAYNUMY=$(($YEARNUM*365)) DAYNUMZ=$(($DAYNUMY+$RNUM)) DAYNUMA=$(($(date +%j)+$DAYNUMZ)) echo $DAYNUMA } Get_Days_From_1970
# 此函数用来获取1970.1.1至今的天数
执行如下:
[aybq76:root]#./1970.sh
16319
[aybq76:root]#date
Fri Sep 5 13:52:57 BEIST 2014
[aybq76:root]#
时间: 2024-10-29 03:47:02