php - 如何将日期字段设置为 3 个月前
问题描述
我正在使用单选按钮从数据库中获取最近 3 个月的记录。我正在使用单选按钮让用户选择三个月前的日期范围。如何将单选按钮的值设置为大约 3 个月前?
<input type="radio" id="test7" name="thismonth" value="<?php echo date("Y-m", strtotime("-3 months"));?>" />
这将值设置为仅一个月,但有没有办法将值设置为恰好三个月前?
解决方案
<?php
$value = $_POST["thismonth"];
// note : name attribute for your input field is 'thismonth', should be something else.
$query = "SELECT *columns* FROM *table* WHERE *date_column* BETWEEN '".$value."' AND '".date('Y-m')."' ";
?>
推荐阅读
- javascript - 在 JavaScript 中没有参数的情况下在 Class-Function 内调用 Event
- javascript - 在Javascript中查找字符串中五个数字的最大序列
- spring - 根据Spring中的另一个配置列表属性为@Scheduled选择cron表达式
- flutter - 我无法添加 appBar
- plotly-dash - Dash Plotly 触发回调
- python - 如何获取一个 mongo 集合中字段的不同值并将其映射到不同集合中的另一个字段。例如
- python - 云函数将 CSV 发送到云存储
- ada - 将 C 库集成到 gnatstudio
- asp.net-core - 如何根据我的 Asp.Net Core Razor 应用程序中 DropdownList 中更改的值加载表单字段?
- c# - 使用 dataTable 填充 dataGrid