note 59946 deleted from function.date by nlopess
| From: | nlopess@php.net | Date: | Tue, 20 Dec 2005 22:40:55 +0000 |
| Subject: | note 59946 deleted from function.date by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-100492@lists.php.net to get a copy of this message | ||
Note Submitter: deadeyepi
Reason: useless
----
Hey all, I used the script from Jay J in our FBLA chapter's website, and i needed to adapt it
to print out the beginning dates and end dates of our conferences. Also, since i have more than one
result, i also had to find a way for the function to be redefined. Below are the results, the files
are separated by **NEW FILE (filename)**
Be sure not to put the **'s and anything between them in your coding, it will cause the code to
crash.
**NEW FILE (mydate.php)**
<?
function mydate($format, $publictime)
{
$sec = substr($publictime, 12, 2);
$min = substr($publictime, 10, 2);
$hour = substr($publictime, 8, 2);
$day = substr($publictime, 6, 2);
$month = substr($publictime, 4, 2);
$year = substr($publictime, 0, 4);
return date($format, mktime($hour, $min, $sec, $month, $day, $year));
unset($year);
unset($day);
unset($month);
unset($sec);
unset($min);
unset($hour);
}
//OK before moving on, save this file as mydate.php and EXIT
?>
**BEFORE MOVING ON, open the file that you want the dates to display in**
**OPEN FILE (The file that the dates will be displayed in.)**
<?
require_once("mydate.php");
//The LOOPHOLE!!!
$datetime = "".MySQL_RESULT($Result,$i,"begdate")."";
//Gets the result from the Query
$justdate = "".MySQL_RESULT($Result,$i,"enddate")."";
//Same as above
echo mydate("Y-m-d", $datetime);
// Produces 2005-09-05 assuming the SQL result is 20050905
echo mydate("Y-m-d", $justdate);
// Produces 2005-09-15 assuming the SQL result is 20050915
?>