输入类型=日期的日期显示为dd-mm-yyyy格式
16lz
2021-01-22
I have my code :
我有我的代码:
<input type="date" class="form-control" id="training_date"
name="training_date" placeholder=" select" value=""
onfocus="(this.type='date')"
onfocusout="(this.type='date')" max=<?php echo date('Y-m-d'); ?>>
I need to display my date in following date-format dd-mm-yyyy format in the textbox
.
我需要在文本框中以下列日期格式dd-mm-yyyy格式显示我的日期。
3 个解决方案
#1
0
What I would recommend is to make a array with the 12 months of the year (because the will never change)
我建议的是在一年中的12个月制作一个阵列(因为永远不会改变)
_currentDate() {
var date = new Date();
for (var i = 0; this.months.length > i; i++) {
if (date.getMonth() === i) {
var displayMonth = this.months[i].month;
}
}
var displayDate = date.getDate() + ' ' + displayMonth + ' ' + date.getFullYear();
return displayDate;
}
Use the value that you return in your function you just need to insert where you want to display it so in your case your input
使用您在函数中返回的值,只需要插入要显示的值,以便输入您的输入
Hope this helps :)
希望这可以帮助 :)
更多相关文章
- 删除复制+粘贴的富文本格式? (跨浏览器)
- 用Node.js编写格式化的JSON
- 我可以使用onBlur事件对TextBox进行日期检查吗?
- Day.js :一个轻量的处理时间和日期的 JavaScript 库
- 使用Isotop过滤日期
- 如何使用Require JS配置具有第三方js依赖项的日期选择器?
- 第三节(JavaScript 对象、日期,函数)
- 希望日期开始结束在一个数组中的while循环中为一个房间ID
- Javascript日期/时间函数是否依赖于客户端机器?