Set timezone in PHP and MySQL

前端 未结 6 1385
闹比i
闹比i 2020-11-30 04:29

I am making an application where I need to store th date in MySQL using the PHP date() function.



        
6条回答
  •  隐瞒了意图╮
    2020-11-30 04:55

    You can do it easily just by the following two lines of PHP.

    $tz = (new DateTime('now', new DateTimeZone('Asia/Kabul')))->format('P');
    $pdo->exec("SET time_zone='$tz';");
    

提交回复
热议问题