Last active
November 4, 2016 05:37
-
-
Save RustingSword/e152b45d2e65a2c920aa to your computer and use it in GitHub Desktop.
计算日期
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATE=08/16/2015 | |
DIFF=$(( ( $(date +%s) - $(date -d "$DATE" +%s ) ) / (24*60*60) )) | |
echo $DIFF | |
echo $(date -d "$DIFF days ago" +%Y%m%d) | |
# ----------------------- | |
FIRST_DAY=20161023 | |
LAST_DAY=20161103 | |
START_DATE=$(( ( $(date +%s) - $(date -d "${FIRST_DAY}" +%s ) ) / (24*60*60) )) | |
END_DATE=$(( ( $(date +%s) - $(date -d "${LAST_DAY}" +%s ) ) / (24*60*60) )) | |
for (( loop=${START_DATE}; loop>=${END_DATE}; loop--)) | |
do | |
DAY=`date -d "${loop} days ago" +%Y%m%d` | |
echo $DAY | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment