diff options
author | redmatrix <mike@macgirvin.com> | 2016-09-26 18:16:43 -0700 |
---|---|---|
committer | redmatrix <mike@macgirvin.com> | 2016-09-26 18:16:43 -0700 |
commit | cacdac16aa104eb1308f69f24fef31f682934fca (patch) | |
tree | 02be2495ad66a7950e342b075144e2fc0958d79d /include/datetime.php | |
parent | fb9544badd66043bf7ee5a7566ba288ad7da29fa (diff) | |
download | volse-hubzilla-cacdac16aa104eb1308f69f24fef31f682934fca.tar.gz volse-hubzilla-cacdac16aa104eb1308f69f24fef31f682934fca.tar.bz2 volse-hubzilla-cacdac16aa104eb1308f69f24fef31f682934fca.zip |
next wave of nulldate fixes
Diffstat (limited to 'include/datetime.php')
-rw-r--r-- | include/datetime.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/include/datetime.php b/include/datetime.php index c72e4bf83..cd08ab367 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -85,15 +85,20 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d if( ($s === '') || (! is_string($s)) ) $s = 'now'; + if(is_null_date($s)) { + $d = new DateTime('0001-01-01 00:00:00', new DateTimeZone('UTC')); + 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)); - } +// 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)); +// } try { $from_obj = new DateTimeZone($from); |