php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78426 Unable to parse supported time format
Submitted: 2019-08-18 03:01 UTC Modified: 2020-11-03 11:53 UTC
From: jianonghe at gmail dot com Assigned: derick (profile)
Status: Not a bug Package: Date/time related
PHP Version: 7.3.8 OS: macOS High Sierra 10.13.6 (17G21
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jianonghe at gmail dot com
New email:
PHP Version: OS:

 

 [2019-08-18 03:01 UTC] jianonghe at gmail dot com
Description:
------------
date_parse('now');

Test script:
---------------
date_parse('now');

Actual result:
--------------
[
  "year" => false,
  "month" => false,
  "day" => false,
  "hour" => false,
  "minute" => false,
  "second" => false,
  "fraction" => false,
  "warning_count" => 0,
  "warnings" => [],
  "error_count" => 0,
  "errors" => [],
  "is_localtime" => false,
]

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-08-18 13:01 UTC] requinix@php.net
-Type: Documentation Problem +Type: Bug -Package: *Regular Expressions +Package: Date/time related
 [2019-08-29 12:44 UTC] jasny@php.net
'now' is a relative time notation. However, the response doesn't contain a 'relative' section as we see with date_parse('+0 seconds')

Expected result:
----------------

[
  "year" => false,
  "month" => false,
  "day" => false,
  "hour" => false,
  "minute" => false,
  "second" => false,
  "fraction" => false,
  "warning_count" => 0,
  "warnings" => [],
  "error_count" => 0,
  "errors" => [],
  "is_localtime" => false,
  "relative" => [
    "year" => 0,
    "month" => 0,
    "day" => 0,
    "hour" => 0,
    "minute" => 0,
    "second" => 0
  ]
]

You can deduct that 'now' was parsed as it's the only value that gives this specific result, however that's merely a workaround.
 [2020-01-20 17:17 UTC] girgias@php.net
-Assigned To: +Assigned To: derick
 [2020-11-03 11:53 UTC] cmb@php.net
-Status: Assigned +Status: Not a bug
 [2020-11-03 11:53 UTC] cmb@php.net
The documentation[1] states:

| 'now'   Now - this is simply ignored

So this is expected behavior.

[1] <https://www.php.net/manual/en/datetime.formats.relative.php>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC