netmaster
netmaster

Reputation: 109

How to Adjust time on php script?

My php script shows time by this

echo "<a href=\"time.php?hits=$hits\">".date("h:i:s A")."</a></div>";

Problem is server time is different from us. Server gives 11 hours back time from my current zone. If my real time is 15 Aug 10 PM server is showing 15 Aug 11 AM!

How can I fast my clock 11 hours on above script?

Upvotes: 0

Views: 161

Answers (3)

Nanhe Kumar
Nanhe Kumar

Reputation: 16297

date_default_timezone_set('America/Los_Angeles');
you can get list of time zones here http://www.php.net/manual/en/timezones.america.php

Upvotes: 1

Young Student
Young Student

Reputation: 131

GOOGLE "PHP timezones change"

putenv("TZ=Europe/London");

or if that produces an error:

date_default_timezone_set('Europe/London');

if you can gain access to your php.ini

date.timezone = "Europe/London"

in the ini

ini_set('date.timezone', 'Europe/London');

OR

for your solution here it is date('h:i:s A', time()+36000) just adjust the seconds my friend

Upvotes: 2

Langdi
Langdi

Reputation: 229

date_default_timezone_set. This changes the time zone for all date-function calls. (See Manual.)

Upvotes: 1

Related Questions