본문 바로가기

PHP/PHP Error

[PHP] Warning: date() [function.date]: It is not safe to rely on the system's timezone settings.

반응형

※ 에러발생


PHP에서 date 함수를 사용하던중 아래와 같은 에러가 발생하였다.


 에러코드

 출력화면

 에러내용

Warning: date() [function.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/Tokyo' for '9.0/no DST' instead in C:\Developer\Apache2.2\htdocs\session02.php on line 13




$time = date('Y-m-d(H:i:s)', $time);


위 코드에서 date( ) 함수를 사용해서 발생한 에러로 해결방법은 아래와 같다.






※ 해결방법



01. date.timezone을 찾고 주석(;)을 제거하고 아래와 같이 수정한다.

     이렇게 설정해야 php에서 date( ) 함수를 사용한 한국시간을 구할 수 있게된다.

  date.timezone = Asia/Seoul




02. 아파치를 Restart 시켜서 다시 실행한다.



03. 에러가 해결된 모습을 확인 할 수 있다.


반응형

'PHP > PHP Error' 카테고리의 다른 글

[PHP] Undefined index 에러 해결방법  (2) 2015.01.07
[PHP] Use of undefined constant ??? - assumed '???' in  (0) 2014.12.23