Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Inconsistent Times

$
0
0

My php script always returns different times.

 

Example: The current time is 4:33pm and the script returns 11:33am.

 

Then sometimes it is correct, and then randomly switches to something like 7:33pm when it should be 5:33pm. This is my code

$time = new DateTime();
$time->setTimezone(new DateTimeZone('America/Chicago'));
$time = $time->format('g:i A');
echo $time;

I don't know if makes any difference, but I'm renting a server from Go Daddy for my website and it is running Linux.

 

How would I fix this problem?

 

Edit: I'm also having a problem with the "time()" function giving results that are hours off.


Viewing all articles
Browse latest Browse all 13200

Latest Images

Trending Articles



Latest Images