Doc #76569 [NEW]: Description of “!” And “|” of DateTime::createFromFormat

From: Date: Mon, 02 Jul 2018 22:59:28 +0000
Subject: Doc #76569 [NEW]: Description of “!” And “|” of DateTime::createFromFormat
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15842@lists.php.net to get a copy of this message
From:             manabu dot matsui at gmail dot com
Operating system: Irrelevant
PHP version:      Irrelevant
Package:          Documentation problem
Bug Type:         Documentation Problem
Bug description:Description of “!” And “|” of DateTime::createFromFormat

Description:
------------
At http://php.net/manual/en/datetime.createfromformat.php,
description
of format character “!” And “|” are as follows:

“!”
Resets all fields (year, month, day, hour, minute, second, fraction and
timezone information) to the Unix Epoch

“|”
Resets all fields (year, month, day, hour, minute, second, fraction and
timezone information) to the Unix Epoch if they have not been parsed
yet

And in the rest of this document, the UNIX epoch is explained as
follows:

> The Unix epoch is 1970-01-01 00:00:00 UTC.

But actually, they appear to reset to 1970-01-01 00:00:00 in the
resulting timezone, not UTC.

% php -d date.timezone=Asia/Tokyo -r
'var_dump(DateTime::createFromFormat("!", ""));'
object(DateTime)#1 (3) {
  ["date"]=>
  string(26) "1970-01-01 00:00:00.000000"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(10) "Asia/Tokyo"
}
% php -d date.timezone=Asia/Tokyo -r
'var_dump(DateTime::createFromFormat("!", "")->getTimestamp());'
int(-32400)
% php -r 'var_dump(DateTime::createFromFormat("!", "", new
DateTimeZone("Asia/Tokyo")));'
object(DateTime)#2 (3) {
  ["date"]=>
  string(26) "1970-01-01 00:00:00.000000"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(10) "Asia/Tokyo"
}

Since the current behavior is more useful, I think this is a problem of
documentation.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=76569&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=76569&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=76569&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=76569&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=76569&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=76569&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=76569&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=76569&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=76569&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=76569&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=76569&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=76569&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=76569&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=76569&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76569&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=76569&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=76569&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=76569&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76569&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=76569&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=76569&r=mysqlcfg



Thread (4 messages)

« previous php.doc.bugs (#15842) next »