php生成年月日下载列表的方法
更新时间:2015年04月24日 14:37:58 作者:不吃皮蛋
这篇文章主要介绍了php生成年月日下载列表的方法,涉及php操作日期的相关技巧,非常具有实用价值,需要的朋友可以参考下
本文实例讲述了php生成年月日下载列表的方法。分享给大家供大家参考。具体实现方法如下:
复制代码 代码如下:
function mdy($mid = "month", $did = "day", $yid = "year", $mval, $dval, $yval)
{
if(empty($mval)) $mval = date("m");
if(empty($dval)) $dval = date("d");
if(empty($yval)) $yval = date("Y");
$months = array(1 => "January", 2 => "February", 3 => "March", 4 => "April", 5 => "May", 6 => "June", 7 => "July", 8 => "August", 9 => "September", 10 => "October", 11 => "November", 12 => "December");
$out = "<select name='$mid' id='$mid'>";
foreach($months as $val => $text)
if($val == $mval) $out .= "<option value='$val' selected>$text</option>";
else $out .= "<option value='$val'>$text</option>";
$out .= "</select> ";
$out .= "<select name='$did' id='$did'>";
for($i = 1; $i <= 31; $i++)
if($i == $dval) $out .= "<option value='$i' selected>$i</option>";
else $out .= "<option value='$i'>$i</option>";
$out .= "</select> ";
$out .= "<select name='$yid' id='$yid'>";
for($i = date("Y"); $i <= date("Y") + 2; $i++)
if($i == $yval) $out.= "<option value='$i' selected>$i</option>";
else $out.= "<option value='$i'>$i</option>";
$out .= "</select>";
return $out;
}
{
if(empty($mval)) $mval = date("m");
if(empty($dval)) $dval = date("d");
if(empty($yval)) $yval = date("Y");
$months = array(1 => "January", 2 => "February", 3 => "March", 4 => "April", 5 => "May", 6 => "June", 7 => "July", 8 => "August", 9 => "September", 10 => "October", 11 => "November", 12 => "December");
$out = "<select name='$mid' id='$mid'>";
foreach($months as $val => $text)
if($val == $mval) $out .= "<option value='$val' selected>$text</option>";
else $out .= "<option value='$val'>$text</option>";
$out .= "</select> ";
$out .= "<select name='$did' id='$did'>";
for($i = 1; $i <= 31; $i++)
if($i == $dval) $out .= "<option value='$i' selected>$i</option>";
else $out .= "<option value='$i'>$i</option>";
$out .= "</select> ";
$out .= "<select name='$yid' id='$yid'>";
for($i = date("Y"); $i <= date("Y") + 2; $i++)
if($i == $yval) $out.= "<option value='$i' selected>$i</option>";
else $out.= "<option value='$i'>$i</option>";
$out .= "</select>";
return $out;
}
希望本文所述对大家的javascript程序设计有所帮助。
相关文章
浅谈Coreseek、Sphinx-for-chinaese、Sphinx+Scws的区别
下面小编就为大家带来一篇浅谈Coreseek、Sphinx-for-chinaese、Sphinx+Scws的区别。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧2016-12-12ThinkPHP5+PhpSpreadsheet实现批量导出数据
由于PHPExcel不再维护,所以建议使用PhpSpreadsheet来导出exlcel,但是PhpSpreadsheet由于是个新的类库,所以只支持PHP7.1及以上的版本,本文给大家介绍了ThinkPHP5+PhpSpreadsheet实现批量导出数据,需要的朋友可以参考下2024-10-10一些PHP Coding Tips(php小技巧)[2011/04/02最后更新]
以下是一些PHP Coding Tips. 当然, 这些Tips并不一定仅仅局限于PHP.大家有什么好的心得, 欢迎直接回复本文与更多的人分享.. 谢谢2011-05-05
最新评论