note 107452 added to datetime.createfromformat
| From: | kamil dot wegrzynowicz at baobaz dot com | Date: | Fri, 10 Feb 2012 08:05:59 +0000 |
| Subject: | note 107452 added to datetime.createfromformat | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186046@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.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.
----
Server IP: 69.147.83.197
Probable Submitter: 81.210.35.114
----
Manual Page -- http://www.php.net/manual/en/datetime.createfromformat.php
Edit -- https://master.php.net/note/edit/107452
Del: integrated -- https://master.php.net/note/delete/107452/integrated
Del: useless -- https://master.php.net/note/delete/107452/useless
Del: bad code -- https://master.php.net/note/delete/107452/bad+code
Del: spam -- https://master.php.net/note/delete/107452/spam
Del: non-english -- https://master.php.net/note/delete/107452/non-english
Del: in docs -- https://master.php.net/note/delete/107452/in+docs
Del: other reasons-- https://master.php.net/note/delete/107452
Reject -- https://master.php.net/note/reject/107452
Search -- https://master.php.net/manage/user-notes.php