note 41812 added to function.strtotime
| From: | briwood at berkeley dot edu | Date: | Thu, 22 Apr 2004 20:12:28 +0000 |
| Subject: | note 41812 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-68543@lists.php.net to get a copy of this message | ||
Some verisions of Oracle return dates in this format by default: e.g. 02-APR-70
Best way around this is to use Oracle's to_char() function:
SELECT to_char(BIRTHDAY,'YYYY-MM-DD') FROM PEOPLE
(PHP 4.3.2 Debian Linux Kernal 2.4.8 #3)
Be very careful of an approach using strtotime() and date() to convert such timestamps. A
strtotime() problem appears prior to 1969.
<?php
$dt = array('16-JUN-03','01-JAN-70', '03-MAY-69',
'29-DEC-69', '01-JAN-68', '04-APR-38');
foreach ($dt as $d) {
print $d ."\n";
print "strtotime: " . strtotime($d) ."\n";
print "strtotime and date: " . date("Y-m-d", strtotime($d))
."\n\n";
}
?>
OUTPUT:
16-JUN-03
strtotime: 1055746800
strtotime and date: 2003-06-16
01-JAN-70
strtotime: 28800
strtotime and date: 1970-01-01
03-MAY-69
strtotime: -20970000
strtotime and date: 1969-05-03
29-DEC-69
strtotime: -230400
strtotime and date: 1969-12-29
01-JAN-68
strtotime: -1
strtotime and date: 1969-12-31
04-APR-38
strtotime: -1
strtotime and date: 1969-12-31
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41812
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41812&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41812&report=yes
Search -- http://master.php.net/manage/user-notes.php