note 56598 deleted from function.mktime by felipe
| From: | felipe@php.net | Date: | Sun, 06 Jan 2008 12:04:37 +0000 |
| Subject: | note 56598 deleted from function.mktime by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134850@lists.php.net to get a copy of this message | ||
Note Submitter: larry at mlxpert dot com
----
I needed a script to display a dropdown menu with a list of week ending dates. I wrote this as a
result. I hope it helps somebody. The selname variable is the name of the select field and the day
of week of the begining date designates the end of the week.
<?php
$selname="we_date";
//Build Begin date
$month=10;
$day=04;
$year=2003;
$hour=date('H');
$min=date('i');
$sec=date('s');
//convert it to unix timestamp
$bdate=mktime($hour,$min,$sec,$month,$day,$year);
//Build Today
$thour=date('H');
$tmin=date('i');
$tsec=date('s');
$tmonth=date('n');
$tday=date('d');
$tyear=date('Y');
//convert it to unix timestamp
$today=mktime($thour,$tmin,$tsec,$tmonth,$tday,$tyear);
//just the weeks
$nbdate=floor($bdate/(7 * 24 * 60 * 60));
$ntoday=floor($today/(7 * 24 * 60 * 60));
//difference between today and the beginning date
$diff=$today-$bdate;
echo "<select size='1' name='$selname'>\n";
while ($bdate <= $today+(7 * 24 * 60 * 60)){
echo ("<option value='".date('n/d/Y',$bdate)."'>
".date('n/d/Y',$bdate)."</option>\n");
$bdate=$bdate+(7 * 24 * 60 * 60);
}
echo "</select>";
?>