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
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.
Password:
Status:
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 Mar 28 15:01:29 2024 UTC