php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mail at oliwel dot de
New email:
PHP Version: OS:

 

 [2011-07-27 09:48 UTC] mail at oliwel dot de
Description:
------------
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:

localtime($iTime)

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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-12 20:56 UTC] heiglandreas@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: heiglandreas
 [2017-01-12 20:56 UTC] heiglandreas@php.net
Looks like localtime does exactly what you were looking for in supported versions of PHP: https://3v4l.org/rMVlY
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 05:01:28 2024 UTC