Php date


#1

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


#2

[quote]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?[/quote]
Uh, do it in PHP.

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

:cool: [color=#6600CC]Atropos[/color] | openvein.org


#3

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: [color=#CC0000]Here[/color] are my Hosting Plan Comparision and $97 off DreamHost Promo Code


#4

Or use PUTENV:

<? PUTENV("TZ=UK/Scotland"); ?>I believe that’s the correct TZ setting.


#5

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) . " ";?>