보안/unix(유닉스)
2020.12.11 unix linux day control (일자조정방법)
MustThanks
2020. 12. 11. 19:08
반응형
# unix 날짜를 제어하는 방법
toDayValue=`date +%Y%m%d`
todayYearValue=`date +%Y`
todayMonthValue=`date +%m`
todayDayValue=`date +%d`
# 한국의 표준시는 KST-9
# 하루전 일자는 KST-9+24 = KST+15
# 이틀전 일자는 KST-9+24+24 = KST+39
# 하루전
yesterDayValue=`TZ=KST+15; date +%Y%m%d`
=====================================
# linux -1 day or -1 days -는 과거 + 는 미래
yesterDayValue=`date -d "+1 day" "+%Y%m%d"`
date -d '1 second ago' 1초 전
date -d '1 hour ago' 1시간 전
date -d 'yesterday' 어제
date -d '1 month ago' 1달 전
date -d '1 year ago' 1년 전
date -d 'last monday' 지난 월요일
date -d '1 second ' 1초 후
date -d '1 hour ' 1시간 후
date -d 'tomorrow' 내일
date -d '1 day' 내일
date -d '1 month' 1달 후
date -d '1 year ' 1년 후
date -d 'next monday' 다음주 월요일