As taken from here http://www.webamoeba.co.uk/site/index.p ... -date-time
BTW mine is Joomla 2.5.6
In addition to the date and time that a JDate object represents, a JDate object can also record a time zone in which we want to output formatted dates. We can set and get this value using the JDate::setOffset() and JDate::getOffset() methods. When we set an offset we are setting the number of hours offset from UTC in which we want to display the date and time. The example below sets the time zone to UTC+1.
To retrieve this value we use the getter method.
$offset = $myDate->getOffset();
Once we have set the offset we can use any of the five methods described in the previous section to get a string representation of the date and time. There are however some important differences between JDate::toFormat() and the other four methods. The JDate::toFormat() method always applies the offset.
// custom format with offset applied
$string = $myDate->toFormat('%Y-%m-%d %H:%M:%S');
The remaining four methods do not apply the offset unless explicitly requested to do so. We can tell these methods to apply the offset using the one and only parameter that all of these methods accept, $local which is by default false. The JDate::toUnix() and JDate::toMySQL() methods do not define the time zone offset in the returned values.
// D, d M Y H:i:s
// Tuesday, 06 October 2009 12:54:37+0000
$rfc2822 = $myDate->toRFC822();
// Tuesday, 06 October 2009 13:54:37 +0100
$rfc2822 = $myDate->toRFC822(true);
$iso8601 = $myDate->toISO8601();
$iso8601 = $myDate->toISO8601(true);
// Unix timestamp
$unix = $myDate->toUnix();
$unix = $myDate->toUnix(true);
// Y-m-d H:i:s
// 2009-10-06 12:54:37
$mysql = $myDate->toMySQL();
// 2009-10-06 13:54:37
$mysql = $myDate->toMySQL(true);
After reading that, I thought I had it all set, but I discovered that working with this offset setup has a nasty issue. Sometimes it kinda goes on the next lower pair level, for example, if you set the offset to 1, it remains 0, but if you set it to 2, it goes up to the correct value of 7200 (secs). My problem was that I wanted to use -5 (-18000) but JDate applied -4 (-14400) which is as useless as not applying any offset at all. I guess I'll go with JFactory::getDate() and work it out with what it has to offer.
Hope it helps.