0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【PHP】XAMPPの時計がズレてるのを直す

Posted at

XAMPPの時計がずれてる

dete関数で時刻を表示したらなぜかズレてました。
これを直していきます。

date("Y年m月d日 H時i分s秒");

スクリーンショット 2025-07-13 17.18.34.png

【方法1】とりあえず今のファイルだけ直したいとき

作業してるphpファイルに以下の記述をかけばOK

<?php
        date_default_timezone_set('Asia/Tokyo');
?>

【方法2】XAMPPのシステム設定から直したい

iniファイルのタイムゾーンを書き換えると直すことができます。

PHPファイルの設定場所

アプリケーション > XAMPP > xamppfiles > etc > php.ini
スクリーンショット 2025-07-13 17.06.32.png

iniファイルの中身

「date.timezone」で検索すると「Europe/Berlin」になっています。

// 修正前
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone=Europe/Berlin

「Asia/Tokyo」に書き換えて保存。

// 修正後
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone=Asia/Tokyo

タイムゾーンが日本の時刻に設定されます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?