diff options
author | Mike Cochrane <mikec@mikenz.geek.nz> | 2008-07-24 19:46:19 -0400 |
---|---|---|
committer | Mike Cochrane <mikec@mikenz.geek.nz> | 2008-07-24 19:46:19 -0400 |
commit | dd3ae36084fe33dd169103429bc1a417ccfb1829 (patch) | |
tree | f8a09f054631c0fac8229a7e20a64ffa8f892bed /lib/util.php | |
parent | 213ecbf35d86c1b0c818889105d7bd7299e648ab (diff) |
Cache the DateTimeZon objects
darcs-hash:20080724234619-533db-015a2751ade3b5b8befb8a735fe89acd4742c4b9.gz
Diffstat (limited to 'lib/util.php')
-rw-r--r-- | lib/util.php | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/util.php b/lib/util.php index 9e3bc3d49..4702bdb63 100644 --- a/lib/util.php +++ b/lib/util.php @@ -941,9 +941,17 @@ function common_date_string($dt) { } function common_exact_date($dt) { + static $_utc; + static $_siteTz; + + if (!$_utc) { + $_utc = new DateTimeZone('UTC'); + $_siteTz = new DateTimeZone(common_timezone()); + } + $dateStr = date('d F Y H:i:s', strtotime($dt)); - $d = new DateTime($dateStr, new DateTimeZone('UTC')); - $d->setTimezone(new DateTimeZone(common_timezone())); + $d = new DateTime($dateStr, $_utc); + $d->setTimezone($_siteTz); return $d->format(DATE_RFC850); } |