Anju
Anju

Reputation: 3

Change timezone in my phpmyadmin shared server

I need to change my timezone to India timezone, but my shared server database showing some junk timezone I tried all the possibility but I can't get the India time zone.

I am using PHP Codeigniter

I Have a contact us page on my website, which saves all the send inquiry details to my mail and database. on that is showing some junk time on it

please help me out of this issue

Upvotes: 0

Views: 883

Answers (1)

Amitesh Kumar
Amitesh Kumar

Reputation: 3079

In the case of shared hosting you would need to contact support guys or go for a live chat and they can change the default time zone for you.

You can use date_default_timezone_set() which sets a default timezone.

Please give a look here

OR

convert all your times to UTC on server side and just work with UTC instead

EDITED ANSWER

What you can do is :

Store your date time in DB in UTC, and while showing You can show Date time By getting current timezone of India.

// create a $dt object with the UTC timezone
$dt = new DateTime('2016-12-12 12:12:12', new DateTimeZone('UTC'));

// change the timezone of the object without changing it's time
$dt->setTimezone(new DateTimeZone('Asia/Kolkata'));

// format the datetime
$dt->format('Y-m-d H:i:s T');

Upvotes: 3

Related Questions