Jmnote bot (토론 | 기여) 잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight)) |
|||
(사용자 2명의 중간 판 21개는 보이지 않습니다) | |||
1번째 줄: | 1번째 줄: | ||
==문제상황== | ==문제상황== | ||
서버 시계는 맞는데, PHP에서 시계가 맞지 않는다. | 서버 시계는 맞는데, PHP에서 시계가 맞지 않는다. | ||
아래 PHP 소스를 실행했더니 8시간 | 아래 PHP 소스를 실행했더니 8시간 느린 시각이 나온다. | ||
< | <syntaxhighlight lang='php'> | ||
echo date("Y-m-d H:i:s", time()); | echo date("Y-m-d H:i:s", time()); | ||
</ | </syntaxhighlight> | ||
<syntaxhighlight lang='console'> | |||
[root@localhost ~]# date | |||
Fri Mar 2 15:31:45 KST 2012 | |||
</syntaxhighlight> | |||
→ 시스템 시계는 정상이며 한국표준시(KST)이다. | |||
==확인== | ==확인== | ||
*phpinfo(); | ===phpinfo=== | ||
*<code>phpinfo();</code>를 확인해보니 다음과 같았다. | |||
{| class='wikitable' | |||
|+date | |||
| date/time support||enabled | |||
|- | |||
| "Olson" Timezone Database Version||2011.8 | |||
|- | |||
| Timezone Database||internal | |||
|- | |||
| Default timezone||Europe/Berlin | |||
|} | |||
{| class='wikitable' | |||
| align="center" style="background:#f0f0f0;"|'''Directive''' | |||
| align="center" style="background:#f0f0f0;"|'''Local Value''' | |||
| align="center" style="background:#f0f0f0;"|'''Master Value''' | |||
|- | |||
| date.default_latitude||31.7667||31.7667 | |||
|- | |||
| date.default_longitude||35.2333||35.2333 | |||
|- | |||
| date.sunrise_zenith||90.583333||90.583333 | |||
|- | |||
| date.sunset_zenith||90.583333||90.583333 | |||
|- | |||
| date.timezone||Europe/Berlin||Europe/Berlin | |||
|} | |||
→ timezone 문제인 것 같다. 베를린은 서울보다 8시간 느리다. | |||
===php.ini=== | |||
<syntaxhighlight lang='console'> | |||
[root@localhost ~]# cat /etc/php.ini | grep timezone | |||
; Defines the default timezone used by the date functions | |||
; http://php.net/date.timezone | |||
date.timezone = Europe/Berlin | |||
</syntaxhighlight> | |||
==적용== | |||
php.ini에 내용을 수정하고 httpd를 재시작했더니 정성화되었다. | |||
<syntaxhighlight lang='text'> | |||
date.timezone = Asia/Seoul | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='bash'> | |||
httpd -k restart | |||
</syntaxhighlight> | |||
==같이 보기== | |||
*[[PHP 시간대 설정]] | |||
[[분류:PHP]] | [[분류:PHP]] | ||
[[분류: | [[분류: 시간대]] |
2020년 11월 2일 (월) 02:35 기준 최신판
1 문제상황[ | ]
서버 시계는 맞는데, PHP에서 시계가 맞지 않는다. 아래 PHP 소스를 실행했더니 8시간 느린 시각이 나온다.
PHP
Copy
echo date("Y-m-d H:i:s", time());
Console
Copy
[root@localhost ~]# date
Fri Mar 2 15:31:45 KST 2012
→ 시스템 시계는 정상이며 한국표준시(KST)이다.
2 확인[ | ]
2.1 phpinfo[ | ]
phpinfo();
를 확인해보니 다음과 같았다.
date/time support | enabled |
"Olson" Timezone Database Version | 2011.8 |
Timezone Database | internal |
Default timezone | Europe/Berlin |
Directive | Local Value | Master Value |
date.default_latitude | 31.7667 | 31.7667 |
date.default_longitude | 35.2333 | 35.2333 |
date.sunrise_zenith | 90.583333 | 90.583333 |
date.sunset_zenith | 90.583333 | 90.583333 |
date.timezone | Europe/Berlin | Europe/Berlin |
→ timezone 문제인 것 같다. 베를린은 서울보다 8시간 느리다.
2.2 php.ini[ | ]
Console
Copy
[root@localhost ~]# cat /etc/php.ini | grep timezone
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Europe/Berlin
3 적용[ | ]
php.ini에 내용을 수정하고 httpd를 재시작했더니 정성화되었다.
text
Copy
date.timezone = Asia/Seoul
Bash
Copy
httpd -k restart
4 같이 보기[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.