Jump to content

Setting timezone with PHP gmmktime()


cwz7

Recommended Posts

Quick example...

 

<?

// usage

// how many hours is the users time +13 <-- 0 --> -12 away from GMT

// ( 15 minutes as ( .25), half hours as ( .5 ), 45 minutes as ( .75 ) )

$user_offset = '-5'; // user is in New York Time

// output format (time display)

$format = 'l dS of F Y h:i:s A';

// time now (GMT) or a timestamp from your database

$time = time();

// run it

echo offset_time ( $time, $format, $user_offset );


function offset_time ( $time_stamp, $time_format, $time_offset )
{ 
return gmdate ( $time_format, $time_stamp + ( 3600 * $time_offset ) );
}

?>

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.