WmZilla - Webmaster and Marketplace

The Next Generation Webmaster and Trade Forum

How to synchronize the time zone between php and mysql

Hashigato

New member

0

0%

Status

Offline

Posts

45

Likes

0

Rep

0

Bits

235

3

Months of Service

0%
Hello everyone, today I had to make sure that both PHP and MySQL have the same time, here's what I did:

PHP:
```PHP
date_default_timezone_set("America/Santiago");
$zona_horaria = date("P"); // timezone in the format MySQL likes
$sql = "set time_zone = '$zona_horaria'";
$mysqli->query($sql);
```

It worked, open to better ideas.
 

249

6,622

6,642

Top