Add DateTime::formatTimestamp() method using the internal timezone

This commit is contained in:
Kijin Sung 2016-02-12 09:09:03 +09:00
parent 540e1ff9d5
commit b7c921bd0a

View file

@ -12,6 +12,19 @@ class DateTime
*/
protected static $_timezones = array();
/**
* Format a Unix timestamp using the internal timezone.
*
* @param string $format Format used in PHP date() function
* @param int $timestamp Unix timestamp (optional, default is now)
* @return string
*/
public static function formatTimestamp($format, $timestamp = null)
{
$offset = Config::get('locale.internal_timezone') ?: date('Z', $timestamp);
return gmdate($format, $timestamp + $offset);
}
/**
* Format a Unix timestamp for the current user's timezone.
*