Jump to content

Archived

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

karthikeyan_coder

Complex time problem.. Gurus can help

Recommended Posts

here is the two functions for showing time in the format "3:57 pm"

[code]function convert_timestamp($timestamp, $timezoneOffset=0) {
$replacements = array(  '-' => '',
' ' => '',
':' => '');
$timestamp = strtr($timestamp, $replacements);

return $timestamp?mktime(
substr($timestamp,8,2),
substr($timestamp,10,2) - $timezoneOffset + $GLOBALS['fc_config']['timeOffset'],
substr($timestamp,12,2),
substr($timestamp,4,2),
substr($timestamp,6,2),
substr($timestamp,0,4)
):0;
}

function format_Timestamp($timestamp, $tzoffset) {
return gmdate($GLOBALS['fc_config']['timeStampFormat'], convert_timestamp($timestamp, $tzoffset));
}[/code]

i need these functions to show US time... how can we change these functions to show US time?

Thank you.

Share this post


Link to post
Share on other sites
Why can't you use the [url=http://www.php.net/date]date()[/url] function to format the time string?

Ken

Share this post


Link to post
Share on other sites
[code]

<?php

echo date("h:i a"); // format 3:57 pm

echo date("h:i a",strtotime('now + 2 hours')); // + 2 hours = 5:57 pm

echo date("h:i a",strtotime('now - 1 hours')); // - 1 hour = 2:57 pm

?>

[/code]

Share this post


Link to post
Share on other sites

×

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.