웹 프로그래밍/PHP, Ubuntu, Linux
PHP - 현재 날짜 가지고 오기 등 날짜 시간 관련
리게인
2023. 4. 28. 20:52
300x250
반응형
현재 날짜 가지고 오기
$today = date("Y-m-d",time());
1달전 날짜 가지고오기
$day = date('Y-m-d', strtotime('-1 month'));
그외 날짜
date("Y-m-d", time()); //오늘
date("Y-m-d", strtotime("-1 week", time())); //최근 일주일
date("Y-m-d", strtotime("-1 month", time())); //최근 1개월
date("Y-m-d", strtotime("-6 month", time())); //최근 6개월
date("Y-m-d", strtotime("-1 year", time())); //최근 1년
응용 ( 6개월전 을 구한다음 하루 뺴기)
$limit_dt = date( 'Y-m-d', strtotime('-1 days', strtotime('-6 month', time())) );
300x250
반응형