PDA

View Full Version : Weird PHP Time


cancer10
10-07-2008, 03:41 PM
Hi,

I am using windows XP and running a local server on my PC.

I am using the following PHP code to generate the current System time:

<?php echo date("g:i a", time()) ;?>

To my surprise, I see the output as 2:36 pm where as my localtime is 8:08 PM

Why is there approx 6.3 hrs of difference b/w my system time and my local server time?


Any help will be appreciated

Thanx

motormichael12
10-07-2008, 03:44 PM
Try this:

<?php echo date("g:i a"); ?>

I believe adding the time() in there changes it from localtime to unix timestamp.

cancer10
10-07-2008, 04:42 PM
even removing that didnt help :(

cancer10
10-07-2008, 04:56 PM
ok seems i have found a solution:

<?php putenv("TZ=Asia/Calcutta");echo date("d M, Y g:i a");?>