was doing a few mods for a site and noticed i had to go around the block to format the time within TT so i modified the following UTC functions to allow you to add what format you want the time to be displayed as.
Open 'backend/functions.php' and find:
now you can simply call :
utc_to_tz_time ('TIME STAMP HERE, 'TIME FORMAT HERE');
or
utc_to_tz ('TIME STAMP HERE, 'TIME FORMAT HERE');
check out [url="http://php.net/manual/en/function.date.php"]http://php.net/manua...nction.date.php[/url] for the list of formats that can be used.
hope this helps
Open 'backend/functions.php' and find:
// Convert UTC to user's timezone
function utc_to_tz ($timestamp=0) {
GLOBAL $CURUSER, $tzs;
if (method_exists("DateTime", "setTimezone")) {
if (!$timestamp)
$timestamp = get_date_time();
$date = new DateTime($timestamp, new DateTimeZone("UTC"));
$date->setTimezone(new DateTimeZone($CURUSER ? $tzs[$CURUSER["tzoffset"]][1] : "Europe/London"));
return $date->format('Y-m-d H:i:s');
}
if (!is_numeric($timestamp))
$timestamp = sql_timestamp_to_unix_timestamp($timestamp);
if ($timestamp == 0)
$timestamp = gmtime();
$timestamp = $timestamp + ($CURUSER['tzoffset']*60);
if (date("I")) $timestamp += 3600; // DST Fix
return date("Y-m-d H:i:s", $timestamp);
}
function utc_to_tz_time ($timestamp=0) {
GLOBAL $CURUSER, $tzs;
if (method_exists("DateTime", "setTimezone")) {
if (!$timestamp)
$timestamp = get_date_time();
$date = new DateTime($timestamp, new DateTimeZone("UTC"));
$date->setTimezone(new DateTimeZone($CURUSER ? $tzs[$CURUSER["tzoffset"]][1] : "Europe/London"));
return sql_timestamp_to_unix_timestamp($date->format('Y-m-d H:i:s'));
}
if (!is_numeric($timestamp))
$timestamp = sql_timestamp_to_unix_timestamp($timestamp);
if ($timestamp == 0)
$timestamp = gmtime();
$timestamp = $timestamp + ($CURUSER['tzoffset']*60);
if (date("I")) $timestamp += 3600; // DST Fix
return $timestamp;
}
Replace with:
// Convert UTC to user's timezone
function utc_to_tz ($timestamp=0, $format='Y-m-d H:i:s') {
GLOBAL $CURUSER, $tzs;
if (method_exists("DateTime", "setTimezone")) {
if (!$timestamp)
$timestamp = get_date_time();
$date = new DateTime($timestamp, new DateTimeZone("UTC"));
$date->setTimezone(new DateTimeZone($CURUSER ? $tzs[$CURUSER["tzoffset"]][1] : "Europe/London"));
return $date->format($format);
}
if (!is_numeric($timestamp))
$timestamp = sql_timestamp_to_unix_timestamp($timestamp);
if ($timestamp == 0)
$timestamp = gmtime();
$timestamp = $timestamp + ($CURUSER['tzoffset']*60);
if (date("I")) $timestamp += 3600; // DST Fix
return date($format, $timestamp);
}
function utc_to_tz_time ($timestamp=0, $format='Y-m-d H:i:s') {
GLOBAL $CURUSER, $tzs;
if (method_exists("DateTime", "setTimezone")) {
if (!$timestamp)
$timestamp = get_date_time();
$date = new DateTime($timestamp, new DateTimeZone("UTC"));
$date->setTimezone(new DateTimeZone($CURUSER ? $tzs[$CURUSER["tzoffset"]][1] : "Europe/London"));
return sql_timestamp_to_unix_timestamp($date->format($format));
}
if (!is_numeric($timestamp))
$timestamp = sql_timestamp_to_unix_timestamp($timestamp);
if ($timestamp == 0)
$timestamp = gmtime();
$timestamp = $timestamp + ($CURUSER['tzoffset']*60);
if (date("I")) $timestamp += 3600; // DST Fix
return $timestamp;
}
now you can simply call :
utc_to_tz_time ('TIME STAMP HERE, 'TIME FORMAT HERE');
or
utc_to_tz ('TIME STAMP HERE, 'TIME FORMAT HERE');
check out [url="http://php.net/manual/en/function.date.php"]http://php.net/manua...nction.date.php[/url] for the list of formats that can be used.
hope this helps