note 78259 added to function.date
| From: | david dot scourfield at llynfi dot co dot uk | Date: | Thu, 04 Oct 2007 17:28:45 +0000 |
| Subject: | note 78259 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131085@lists.php.net to get a copy of this message | ||
Two comments below give us superfluous code.
Firstly, arkin AT REMOVESPAM DOT arkinex DOT com has posted a function that "takes 2007-09-19
21:05:23 and turns it into a unix timestamp." The built-in PHP function strtotime() can do
this, so defining another function is unnecessary:
<?php
$timestamp = strtotime("2007-09-19 21:05:23");
?>
And secondly, vikram dot dhanjal at gmail dot com gives us "Code for generating time stamp for
current time." Again, strtotime() can do this, but PHP also has a built-in function for that
very purpose: time().
<?php
$timestampRightNow = strtotime("Now");
// or simpler still:
$timestampRightNow = time();
?>
time() is quicker than strtotime("Now") as PHP does not need to parse the string provided.
----
Server IP: 69.147.83.197
Probable Submitter: 90.203.38.236
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/78259
Del: integrated -- https://master.php.net/note/delete/78259/integrated
Del: useless -- https://master.php.net/note/delete/78259/useless
Del: bad code -- https://master.php.net/note/delete/78259/bad+code
Del: spam -- https://master.php.net/note/delete/78259/spam
Del: non-english -- https://master.php.net/note/delete/78259/non-english
Del: in docs -- https://master.php.net/note/delete/78259/in+docs
Del: other reasons-- https://master.php.net/note/delete/78259
Reject -- https://master.php.net/note/reject/78259
Search -- https://master.php.net/manage/user-notes.php