我正在尝试在日期1到9中添加0,因为日期列在下拉菜单中.这是我的代码,我认为使用d会添加前导零,但似乎没有工作.我没有太多的PHP经验,所以这是一个远景...谢谢你的先进!
<?PHP
FUNCTION DateSelector($inName, $useDate=0)
{
/* create array so we can name months */
$monthName = ARRAY(1=> "January", "February", "March",
"April", "May", "June", "July", "August",
"September", "October", "November", "December");
/* if date invalid or not supplied, use current time */
IF($useDate == 0)
{
$useDate = TIME();
}
/* make month selector */
ECHO "<SELECT NAME=" . $inName . "month>\n";
FOR($currentMonth = 1; $currentMonth <= 12; $currentMonth++)
{
ECHO "<OPTION VALUE=\"";
ECHO INTVAL($currentMonth);
ECHO "\"";
IF(INTVAL(DATE( "m", $useDate))==$currentMonth)
{ …Run Code Online (Sandbox Code Playgroud)