Reputation: 359
I have created a table where the payment time is payment_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
into my database. When I insert a value while keeping the payment_time field blank, the time has stored on GMT -7 where I am staying in GMT +00. I think it is because the server time zone is GMT -7. How can I insert my local time into database? Even if it is not possible then I want at least to get the local time when on output from database(I mean while query).
Upvotes: 1
Views: 2023
Reputation: 11
Check out this. http://dev.mysql.com/doc/refman/5.5/en//time-zone-support.html
To change global time zone:
mysql> SET GLOBAL time_zone = timezone;
Upvotes: 1
Reputation: 607
Put the time zone setting command in that script from where you are inserting the time SET time_zone = 'country_name/city';
you can go through the links of different country and states in php website.
Suppose i am executing xyz.php script which will insert time into database, then it should look like this
<?php date_default_timezone_set('Asia/Kolkata'); //you ned to put this line of code at the start of the script ?>
Upvotes: 0