본문 바로가기
Programming/web

[PHP] It is not safe to rely on the system's timezone settings warning 발생

by 유주원 2015. 10. 27.

php에서 date() 함수를 실행 한 후 웹상에서 해당 php를 실행 시켰더니 아파치에서 아래와 같은 warning 메시지가 발생한다.


PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning. you most likely misspelled the timezone identifier. We selected 'Asia/Seoul' for 'KST/9.0/no DST' instead in ......


물론 무시해도 잘 동작하긴 하지만 무언가가 찝찝하다.

에러 내용을 보내 대충 timezone 설정이 안맞는것 같다. 

php의 timezone 설정을 해주도록 하자.


/etc/폴더의 php.ini 파일을 연다.

$> vi /etc/php.ini


[Date]라고 써 있는 항목을 찾으면 아래와 같이 주석처리 되어 있는 것을 확인할 수 있다.

[Date]

;date.timezone =


주석을 해제하고 timezone 옆에 Asia/Seoul을 입력해 주자.

[Date]

date.timezone = Asia/Seoul


아파치를 다시 재기동한 후 php에 접근해 보면 더이상 warning 메시지가 나타나지 않는 것을 확인할 수 있다.

$> sudo /etc/rc.d/init.d/httpd restart