php date

php date

Posted by: Anonymous
Posted on: 2006-09-16 11:49:00

I would like to put a simple php date onto a web page. But, i am in a different time zone (4000 miles away). So I would get a date of something like 11:36, instead of 19:46 as it is here in sunny Scotland. This is because the server is located in another time zone, I think..

Can this be sorted by myself, can't see anything in the web panel to help me out?

Apologies for posting in this section, but I have mislaid my password :lol:

Cheers

Andy

Re: php date

Posted by: Atropos7
Posted on: 2006-09-16 13:18:00

In reply to:

I would like to put a simple php date onto a web page. But, i am in a different time zone (4000 miles away). So I would get a date of something like 11:36, instead of 19:46 as it is here in sunny Scotland. This is because the server is located in another time zone, I think..

Can this be sorted by myself, can't see anything in the web panel to help me out?


Uh, do it in PHP.

$timezone_offset = 1;
$timestamp = gmdate($format, time() + 3600*$timezone_offset);



cool Atropos | openvein.org

Re: php date

Posted by: hbchbc
Posted on: 2006-09-18 08:01:00

Here is my suggestion:

if ( version_compare(phpversion(),'5.1') == 1 )  {
if ( function_exists('date_default_timezone_get') ) {
$timezone = date_default_timezone_get();
if ( $timezone != 'YOURZONE' ) {
date_default_timezone_set('YOURZONE');
}
}
}

wink Here are my Hosting Plan Comparision and $97 off DreamHost Promo Code

Re: php date

Posted by: desilucy
Posted on: 2006-09-20 19:42:00

Or use PUTENV:

<?
PUTENV("TZ=UK/Scotland");
?>

I believe that's the correct TZ setting.

Re: php date

Posted by: ~andy~
Posted on: 2006-09-28 15:04:00

Hi guys thanks for the info.

I used this code instead of any code with a calculation in it. The clocks go forward an hour in the Spring and back an hour in the Autumn over here - and this code seems to save me having to alter anything manually?


<?php $now = time();
$original_tz = $_ENV["TZ"];
putenv("TZ=Europe/Edinburgh");
echo "The time in Scotland is " . date ("H:i, l j F Y", $now) . "
";
putenv("TZ=Europe/Paris");
echo "The time in Paris is " . date ("H:i, l j F Y", $now) . "
";
putenv("TZ=Europe/Kiev");
echo "The time in Kiev is " . date ("H:i, l j F Y", $now) . "
";
putenv("TZ=Europe/Tblisi");
echo "The time in Tblisi is " . date ("H:i, l j F Y", $now) . "
";
putenv("TZ=Atlantic/Faeroe");
echo "The time in Tórshavn is " . date ("H:i, l j F Y", $now) . "
";
putenv("TZ=Europe/Vilnius");
echo "The time in Vilnius is " . date ("H:i, l j F Y", $now) . "
";
putenv("TZ=Europe/Rome");
echo "The time in Rome is " . date ("H:i, l j F Y", $now) . "
";?>

Tags: phpapologiescheersweb panellolpasswordhelptime zone