Php 如何将日期字段设置为3个月前
我使用单选按钮从数据库中获取过去3个月的记录。我使用一个单选按钮为用户选择日期范围,三个月前。 如何将单选按钮的值设置为大约3个月前Php 如何将日期字段设置为3个月前,php,mysql,Php,Mysql,我使用单选按钮从数据库中获取过去3个月的记录。我使用一个单选按钮为用户选择日期范围,三个月前。 如何将单选按钮的值设置为大约3个月前 <input type="radio" id="test7" name="thismonth" value="<?php echo date("Y-m", strtotime("-3 months"));?>" /> 像这样尝试: <?$effectiveDate=date('y-m-d'); $effectiveDate = s
<input type="radio" id="test7" name="thismonth" value="<?php echo date("Y-m", strtotime("-3 months"));?>" />
像这样尝试:
<?$effectiveDate=date('y-m-d');
$effectiveDate = strtotime("-3 months", strtotime($effectiveDate)); ?>
<input type="radio" id="test7" name="thismonth" value="<?php echo effectiveDate?>" />
我在你的代码中没有看到访问你数据库的尝试…@Akhil,这个问题看起来像MySQL部分,但你正在显示HTMLI,请确认有没有办法设置单选按钮从前3个月到本月的值?问题在你的查询中,告诉我们你的查询这是一种创建查询的危险方式。请使用准备好的语句/参数化查询。@Christiaan这只是为了演示,让他理解。
<?$effectiveDate=date('y-m-d');
$effectiveDate = strtotime("-3 months", strtotime($effectiveDate)); ?>
<input type="radio" id="test7" name="thismonth" value="<?php echo effectiveDate?>" />