note 43910 added to function.date

From: Date: Thu, 08 Jul 2004 07:09:11 +0000
Subject: note 43910 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-72865@lists.php.net to get a copy of this message
Beware! If you use a variable that contains a timestamp (for instance when retrieving values from a database), then watch out for empty values. An empty value will be displayed as the first possible date. For example: $my_timestamp=NULL; $my_date=date("d-m-Y", $my_timestamp); Then: echo($my_date); Will display ' 01-01-1970 '. The if-statement to prevent this is very straightforward, but you have to be aware of the fact that date("format", timestamp) will always try to return something. Even for a NULL value or a "" value. Only when you try to use negative integers as timestamp will a warning be generated. ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43910 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43910&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43910&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#72865) next »