note 41812 deleted from function.strtotime by derick
| From: | derick@php.net | Date: | Sun, 14 Aug 2005 11:48:23 +0000 |
| Subject: | note 41812 deleted from function.strtotime by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-93586@lists.php.net to get a copy of this message | ||
Note Submitter: briwood at berkeley dot edu
----
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