note 107452 modified in datetime.createfromformat by googleguy
| From: | googleguy@php.net | Date: | Fri, 04 Apr 2014 18:49:52 +0000 |
| Subject: | note 107452 modified in datetime.createfromformat by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-199186@lists.php.net to get a copy of this message | ||
It seems that a pipe ('|') option in formating string works only with PHP version 5.3.7
and newer. We had an issue with it on versions 5.3.2, 5.3.3, 5.3.6. Yet it was fine with 5.3.8 and
5.3.10.
By short example:
<?php
$timezone = new DateTimeZone('UTC');
$dateTime = DateTime::createFromFormat('dmY|', '01011972', $timezone);
//$dateTime is FALSE in PHP v <5.3.8
?>
Instead we used a workaround:
<?php
$dateTime = DateTime::createFromFormat('dmY', '01011972', $timezone);
$dateTime->format('Y-m-d 00:00:00');
?>
which works fine.
====
Modified by admin to correct for version (5.3.7 not 5.3.8)
--was--
It seems that a pipe ('|') option in formating string works only with PHP version 5.3.8
and newer. We had an issue with it on versions 5.3.2, 5.3.3, 5.3.6. Yet it was fine with 5.3.8 and
5.3.10.
By short example:
<?php
$timezone = new DateTimeZone('UTC');
$dateTime = DateTime::createFromFormat('dmY|', '01011972', $timezone);
//$dateTime is FALSE in PHP v <5.3.8
?>
Instead we used a workaround:
<?php
$dateTime = DateTime::createFromFormat('dmY', '01011972', $timezone);
$dateTime->format('Y-m-d 00:00:00');
?>
which works fine.
http://php.net/manual/en/datetime.createfromformat.php