note 40183 added to function.localtime
| From: | tony at speedscript dot com | Date: | Tue, 24 Feb 2004 15:35:47 +0000 |
| Subject: | note 40183 added to function.localtime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65652@lists.php.net to get a copy of this message | ||
Date select box for the current week, or whatever week you give for an offset (in seconds), returns
the string you can echo with the select box named $name:
function week_date_selectbox( $time_offset, $name )
{
if( isset( $time_offset ) )
$t = time() + $time_offset;
else
$t = time();
$wday = array("Sun ","Mon ","Tue ","Wed ","Thu
","Fri ","Sat ");
$mon = array("Jan ","Feb ","Mar ","Apr ","May
","Jun ","Jul ","Aug ","Sep ","Oct
","Nov ","Dec ");
$mybox = "<select name=\"$name\">\n";
for($ii = 0; $ii > -6; $ii--)
{
$tarr = localtime( $t + $ii * 86400, 1 );
if( $tarr["tm_wday"] == 0 )
{
// found Sunday, now make the week's strings
for($jj = 0; $jj < 7; $jj++)
{
$tarr = localtime( $t + ($jj + $ii) * 86400, 1 );
$mybox .= sprintf( " <option value=\"%04d-%02d-%02d\">%s%s%d
%d</option>\n",
((int)$tarr["tm_year"] + 1900),
$tarr["tm_mon"],
((int)$tarr["tm_mday"] + 1),
$wday[$tarr["tm_wday"]],
$mon[$tarr["tm_mon"]],
(int)$tarr["tm_mday"],
((int)$tarr["tm_year"] + 1900) );
}
break;
}
}
$mybox .= "</select>\n";
return $mybox;
}
----
Manual Page -- http://www.php.net/manual/en/function.localtime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40183
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40183&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40183&report=yes
Search -- http://master.php.net/manage/user-notes.php