aboutsummaryrefslogtreecommitdiffstats
path: root/include/datetime.php
diff options
context:
space:
mode:
authorMike Macgirvin <mike@macgirvin.com>2010-09-08 20:14:17 -0700
committerMike Macgirvin <mike@macgirvin.com>2010-09-08 20:14:17 -0700
commitffb1997902facb36b78a7cfa522f41f2b3d71cda (patch)
treee9fe47acf26c5fd2c742677f2610b60d3008eb26 /include/datetime.php
parentb49858b038a0a05bbe7685929e88071d0e125538 (diff)
downloadvolse-hubzilla-ffb1997902facb36b78a7cfa522f41f2b3d71cda.tar.gz
volse-hubzilla-ffb1997902facb36b78a7cfa522f41f2b3d71cda.tar.bz2
volse-hubzilla-ffb1997902facb36b78a7cfa522f41f2b3d71cda.zip
mistpark 2.0 infrasturcture lands
Diffstat (limited to 'include/datetime.php')
-rw-r--r--include/datetime.php17
1 files changed, 14 insertions, 3 deletions
diff --git a/include/datetime.php b/include/datetime.php
index 15d688530..d241f779e 100644
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -55,9 +55,20 @@ function select_timezone($current = 'America/Los_Angeles') {
if(! function_exists('datetime_convert')) {
function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d H:i:s") {
- $d = new DateTime($s, new DateTimeZone($from));
- $d->setTimeZone(new DateTimeZone($to));
- return($d->format($fmt));
+
+ // Slight hackish adjustment so that 'zero' datetime actually returns what is intended
+ // otherwise we end up with -0001-11-30 ...
+ // add 32 days so that we at least get year 00, and then hack around the fact that
+ // months and days always start with 1.
+
+ if(substr($s,0,10) == '0000-00-00') {
+ $d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
+ return str_replace('1','0',$d->format($fmt));
+ }
+
+ $d = new DateTime($s, new DateTimeZone($from));
+ $d->setTimeZone(new DateTimeZone($to));
+ return($d->format($fmt));
}}
function dob($dob) {