February 26, 2012
PHP & MySQL date
Question by Ayman Jitan
I am trying to insert in a field of type “timestamp” in MySQL database “CURRENT_TIMESTAMP” and its 2012-2-26 10:04:34 AM in my local are and its the time on my pc
but the thing is that I find it 2012-02-26 02:04:34 in my database
everytime I insert I find different values from my local time
and aslo if I do
echo strtotime('now');
it prints the same value “2012-02-26 02:04:34”
how can I fix , knowing that I am working on a schedule needs to perform operations on a certain time
Answer by Starx
This looks like problem with time zones. Check them in php.ini
. Or as suggested my Cheery on the comment, use [docs here]
<?php
date_default_timezone_set('America/Los_Angeles');
?>
However, You should make sure you are using correct methods to input the date and time in the database. There are two ways to do so.