I would like to save at mysql in UTC timezone and read with PHP using America/Sao_Paulo timezone.
Im using YII framework.
Its not working property, how could I do that?
main.php:
'timezone' => 'America/Sao_Paulo',
'db'=>array(
...
'initSQLs'=>array("SET time_zone = '+00:00'"),
...
)
Do this in your PHP code:
Now PHP operates in UTC. It’s up to you to convert to user local times but you have a common ground.
And in MySQL use
UTC_TIMESTAMP()for yourDATETIMEneeds. It uses UTC time regardless of the MySQL settings so you don’t need to worry anymore.