Jump to content

TImezone


pasanewa

Recommended Posts

I have to a problem..

 

<?

      echo "Original Time: ". date("h:i:s")."\n";

      putenv("TZ=Asia/kathmandu");

      echo "New Time: ". date("h:i:s a")."\n";

?>

 

 

=> I am testing this in Kathmandu. So this must display...

Original Time: 02:26:22 pm New Time: 02:26:22

 

BUT it is showing ..

 

Original Time: 02:26:17 New Time: 08:41:17 am

 

 

WHY ?? why is it showing wrong time..??

 

Where ever the site is run, i have to display the Nepali time..

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/46104-timezone/
Share on other sites

read the date() function in the php manual for settign the appropriate timezone in your script

 

YOU CAN SET THE TIMEZONE IN YOUR SCRIPT WITH PHP 5

 

YOU CAN SET THE DEFALT TIMEZINE IN YOUR PHP.INI FILE WITH PHP 4

 

if you dont' have control over your php.ini file (freehosting)

then you have to create a workaround to convert your current timezone time output to the the time that you want

 

for example my timezone is 5 PM now, but my php script is echoing 7PM

i can create a function that will subtract 2 from the current hour date(h) - 1

 

 

there are plenty of user created workarounds for php 4 as well on the comments for php function DATE and TIME

 

-good luck

Link to comment
https://forums.phpfreaks.com/topic/46104-timezone/#findComment-224023
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.