날짜 관련 shell

os/UNIX_LINUX 2010. 8. 23. 16:00
반응형



#vi date_test.sh
NowDateYYYY=`date '+%Y'`
NowDateMM=`date '+%m'`
NowDateDD=`date '+%d'`
NowDateYYYYMM=`date '+%Y%m'`
NowDateYYYYMMDD=`date '+%Y%m%d'`
NowDateYYYYMMDDHH=`date '+%Y%m%d%H'`
NowDateYYYYMMDDHHMM=`date '+%Y%m%d%H%M'`
NowDateYYYYMMDDHHMMSS=`date '+%Y%m%d%H%M%S'`

echo $NowDateYYYY
echo $NowDateMM
echo $NowDateDD
echo $NowDateYYYYMM
echo $NowDateYYYYMMDD
echo $NowDateYYYYMMDDHH
echo $NowDateYYYYMMDDHHMM
echo $NowDateYYYYMMDDHHMMSS

 


# sh date_test.sh
2010
08
23
201008
20100823
2010082315
201008231557
20100823155731
#



하루전 날짜(1일전 날짜)
PREV_1DAY_YYYYMMDD=`TZ=KST+15 date '+%Y%m%d'`
echo $PREV_1DAY_YYYYMMDD


2일전 날짜

PREV_2DAY_YYYYMMDD=`TZ=KST+39 date '+%Y%m%d'`
echo $PREV_2DAY_YYYYMMDD


현재시간에서 2분후의 시간

NOW_DATE_PLUS_2MINUTE=`TZ=KST-9:02:00 date '+%Y%m%d%H%M%S'`

echo $NOW_DATE_PLUS_2MINUTE


반응형
Posted by 공간사랑
,