[PHP] 日期函數『搭配javascript』
May 27th, 2007 by appleboy 參觀者:1,009Views 機器人:449Views
剛剛發現一個好玩的函數,用在購物車的時候,可以選擇發表團購日期,跟結束日期,下面我是設定發起日後14天之內要下架,還不錯用
大家參考看看吧,其實做出很多功能,大家修改函數就可以了
function jmp2_date_ex($str,$str1,$str2,$sy,$ey){
global $$str;
$$str=str_replace("-","/",$$str);
$nextWeek = time() + (14 * 24 * 60 * 60);
$sy=date("Ymd");
$ey=date("Ymd",$nextWeek);
echo "<input id='$str' name='$str' type='text' size=8 value='".$$str."' readonly style='height:18;font-size:9pt'>";
?>
<script language="javascript">
Calendar.setup({
inputField : "<? echo $str;?>", // id of the input field
ifFormat : "%Y/%m/%d", // format of the input field
cal_ondate : "<? echo $sy;?>",
cal_offdate : "<? echo $ey;?>",
button : "<? echo $str;?>" // trigger for the calendar (button ID)
});
</script>
<?
}
global $$str;
$$str=str_replace("-","/",$$str);
$nextWeek = time() + (14 * 24 * 60 * 60);
$sy=date("Ymd");
$ey=date("Ymd",$nextWeek);
echo "<input id='$str' name='$str' type='text' size=8 value='".$$str."' readonly style='height:18;font-size:9pt'>";
?>
<script language="javascript">
Calendar.setup({
inputField : "<? echo $str;?>", // id of the input field
ifFormat : "%Y/%m/%d", // format of the input field
cal_ondate : "<? echo $sy;?>",
cal_offdate : "<? echo $ey;?>",
button : "<? echo $str;?>" // trigger for the calendar (button ID)
});
</script>
<?
}
隨機主題
