php - How to enable date input and re format it ready for mysqli insert or select
问题描述
I am wanting to allow the date input in a html form to be
UK Format - DD/MM/YYYY , when submitted, before any php code is executed in the sense of queries... e.g. select, insert etc etc...
I want php to change the date inputted DD/MM/YYYY to YYYY-MM-DD
HTML
<div class="form-group col-mb-3">
<label for="betDate"> Date</label>
<input type="text" class="form-control" name="Date" id="Date" placeholder="Date" value="">
</div>
<div class="form-group col-mb-3">
<label for="sport">Sport</label>
<input type="text" class="form-control" name="sport" id="sport" placeholder="sport" >
</div>
解决方案
在您的输入中使用“日期”类型,您还可以限制允许设置的日期范围。
<input type="date" min="2019-02-01" max="2019-02-02">
您将看到正在观看该网站的国家/地区的格式,例如伦敦,当您使用 php 发送表单时,将(始终)将其转换为数据库格式(yyyy-mm-dd)。
推荐阅读
- android - Kotlin 中未解决的参考 WearableRecyclerView.Adapter 错误
- blogger - Blogger 最近的帖子小部件图像调整大小 /s72-c
- css - 删除dashboardSidebar中splitLayout中列之间的间隙
- pywinauto - pywinauto 在 windows 上安装应用程序
- javascript - (不和谐)SQLite 2 值 1 列错误
- c# - 空间域中的图像卷积
- php - 在 jquery 智能向导上添加功能
- c++ - jsoncpp写入只有一个元素的json数组
- github - 当 Circle CI 跳过测试时,Github 如何与 Circl-CI 配合使用?
- elasticsearch - 获取从 multiJson 对象创建的 PostData 字符串(json)表示