note 86395 deleted from function.getdate by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 08:03:08 +0000 |
| Subject: | note 86395 deleted from function.getdate by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196768@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
I couldn't get the last 2 examples of gmgetdate() to work, so here's a modification that
did work for me that behaves exactly like getdate() :
<?php
function gmgetdate($timestamp = null) {
if (is_null($timestamp)) { $timestamp = time(); }
$dateParts = array(
'mday' => 'j',
'wday' => 'w',
'yday' => 'z',
'mon' => 'n',
'year' => 'Y',
'hours' => 'G',
'minutes' => 'i',
'seconds' => 's',
'weekday' => 'l',
'month' => 'F',
0 => 'U'
);
while (list($part, $format) = each($dateParts)) {
$GMdateParts[$part] = gmdate($format, $timestamp);
}
return $GMdateParts;
}
?>