Wilest
Wilest

Reputation: 1870

php getdate() - Hour not correct

I'm using php in an iframe for a counter. I am using the getdate(); function. My local time is no 12:16PM and if I use the getdate(); from php to get the local time now, the hour displays as 13. Should my answer from php getdate() not be 12?

$d1=getdate();
$hournew=$d1['hours'];
echo $hournew . " ";

Upvotes: 2

Views: 592

Answers (1)

Avisek Chakraborty
Avisek Chakraborty

Reputation: 8309

First do a-

echo date_default_timezone_get();

check if it is your timezone or not.

Surely it is not, then set your timezone at the top-

date_default_timezone_set('America/Los_Angeles');

Here is the list of timezones.

Upvotes: 6

Related Questions