本文介绍了如何删除datetime-local输入类型中的时间值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在HTML中使用 datetime-local input 类型,但是我不想使用时间一部分。我只想获取日期。 < input type = datetime-local name = book_date id = book_date> 这是我从输入字段: 2018-04-22T03:02 我想要: 2018-04-22 还是如何从该值中删除时间部分?解决方案如果只需要日期部分,请使用 type = date : < input type = date name = book_date id = book_date onchange = console.log(此。值); /> 如果您真的想使用 type = datetime-local ,您只需将值除以 T : < input type = datetime-local name = book_date id = book_date onchange = console.log (this.value.split('T')[0]); /> I am using datetime-local input type in HTML, but I don't want to use the time portion. I want to only get the date.<input type="datetime-local" name="book_date" id="book_date">This is the output I get from the input field:2018-04-22T03:02I want:2018-04-22Or how to remove the time portion from this value? 解决方案 If you only want the date portion, use type="date":<input type="date" name="book_date" id="book_date" onchange="console.log(this.value);" />If you really want to use type="datetime-local", you can simply split the value by T:<input type="datetime-local" name="book_date" id="book_date" onchange="console.log(this.value.split('T')[0]);" /> 这篇关于如何删除datetime-local输入类型中的时间值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-04 03:10
查看更多