echo date('Y-m-d', strtotime(date('Y-m-d').'-1 month'))
echo date('Y-m-d', strtotime('-2 month')); // 2달전
쉘에서 바로 실행하기
php -r "echo date('Y-m-d', strtotime(date('Y-m-d').'-1 month'));"
50일전
echo date('Y-m-d', strtotime(date('Y-m-d').'-50 day'))
1년 후
echo date('Y-m-d', strtotime(date('Y-m-d').'+1 year'))
Y-m-d 를 Y-m-d H:i:s 로 변경하면 “연월일”을 “연월일 시분초”로 바꿀 수 있다.
Be First to Comment