|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #55292 localtime should default to current time if "NULL" is passed
Submitted: 2011-07-27 09:48 UTC Modified: 2017-01-12 20:56 UTC
From: mail at oliwel dot de Assigned: heiglandreas (profile)
Status: Closed Package: Date/time related
PHP Version: 5.3.6 OS: Linux
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: mail at oliwel dot de
New email:
PHP Version: OS:


 [2011-07-27 09:48 UTC] mail at oliwel dot de
It would be nice to make localtime() to use the current time as a default if the passed time argument is NULL.
Reason: It makes a lot of extra work if the localtime call is called with an optional timestamp parameter passed from outside

Test script:
localtime(is_null($iTime) ? time() : $iTime)

should be shorter:


where time is a timestamp or null for the current time. At the moment NULL is interpreted as 0 which is not what (at least) I expect.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-12 20:56 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: heiglandreas
 [2017-01-12 20:56 UTC]
Looks like localtime does exactly what you were looking for in supported versions of PHP:
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Jun 06 19:03:38 2023 UTC