|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78509 Calling time() with parameter(s) returns NULL
Submitted: 2019-09-07 12:25 UTC Modified: 2019-09-07 18:19 UTC
From: gvre at gvre dot gr Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 7.3 OS:
Private report: No CVE-ID: None
 [2019-09-07 12:25 UTC] gvre at gvre dot gr
Calling the "time()" function with a parameter works fine in PHP <= 7.2.x and returns an int. In PHP 7.3, it returns NULL and produces a "Warning: time() expects exactly 0 parameters, 1 given" message instead.

I know that passing a parameter to time() is wrong, but I think it could produce a warning and return the value in PHP 7.3 (and 7.4 maybe), since it works fine in 7.2 and is common in C to call it that way. 
I did not find anything related to deprecation pages, so it may be useful to document this behavior as deprecated in case you decide to keep it as is.

Test script:

Expected result:
The current Unix timestamp.

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-07 15:04 UTC]
-Status: Open +Status: Not a bug -Operating System: Linux +Operating System: -PHP Version: 7.3Git-2019-09-07 (Git) +PHP Version: 7.3
 [2019-09-07 15:04 UTC]
This is not a bug on PHP's side, moreover this will throw an ArgumentCountError as of PHP 8. [1]

 [2019-09-07 18:19 UTC] gvre at gvre dot gr
It is very good that PHP 8 will be throwing an ArgumentCountError in such cases, but the change introduced in 7.3 breaks code that works in all previous versions (4.3.0 - 7.2.22). Ideally, 7.3 should be creating a warning and a later version be stricter if needed. It would also be helpful for people who want to upgrade to be aware of that change.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 22 11:01:32 2024 UTC