note 78259 deleted from function.date by felipe
| From: | felipe@php.net | Date: | Sun, 09 Dec 2007 13:22:46 +0000 |
| Subject: | note 78259 deleted from function.date by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-132983@lists.php.net to get a copy of this message | ||
Note Submitter: david dot scourfield at llynfi dot co dot uk
----
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.