我使用 jQuery UI 中的日期选择器,但格式类似于今天的示例:08/01/2013
但我希望今天的格式是示例:2013-08-01
这是我认为也许我应该使用的代码行?
`$("#txtFromDate").datepicker("option", "dateFormat", "yyyy-mm-dd");`这是我使用的 jQuery 代码,它工作正常,但不知道该放在哪里?我想要我的两个领域的格式.
<前>`$(文档).ready(函数(){$("#txtFromDate").datepicker({minDate: "07/17/2012",最大日期:0D",numberOfMonths:2,onSelect:函数(选定){$("#txtToDate").datepicker("option","minDate", selected);}});$("#txtToDate").datepicker({minDate: "07/17/2013",最大日期:0D",numberOfMonths:2,onSelect:函数(选定){$("#txtFromDate").datepicker("option","maxDate", selected);}});});`我希望有人对此有解决方案:-)
因为你在 datepicker 中已经有其他选项了...把它添加到那里.
试试这个
$("#txtFromDate").datepicker({minDate: "07/17/2012",最大日期:0D",numberOfMonths:2,dateFormat: "yy-mm-dd",//<----这里onSelect:函数(选定){$("#txtToDate").datepicker("option","minDate", selected);}});I use the datepicker from jQuery UI, but the format is like example today: 08/01/2013
But i want the format to be example today: 2013-08-01
Here is code line i think maybe i should use?
`$( "#txtFromDate" ).datepicker( "option", "dateFormat", "yyyy-mm-dd" );`
And here is my jQuery code i use that works fine but don't know where to put the line? And i want the format in both of my fields.
`
$(document).ready(function(){
$("#txtFromDate").datepicker({
minDate: "07/17/2012",
maxDate: "0D",
numberOfMonths: 2,
onSelect: function(selected) {
$("#txtToDate").datepicker("option","minDate", selected);
}
});
$("#txtToDate").datepicker({
minDate: "07/17/2013",
maxDate:"0D",
numberOfMonths: 2,
onSelect: function(selected) {
$("#txtFromDate").datepicker("option","maxDate", selected);
}
});
});`
I hope somebody have a solution for this :-)
since your already have other options in the datepicker... add it there.
try this
$("#txtFromDate").datepicker({
minDate: "07/17/2012",
maxDate: "0D",
numberOfMonths: 2,
dateFormat: "yy-mm-dd", //<----here
onSelect: function(selected) {
$("#txtToDate").datepicker("option","minDate", selected);
}
});
这篇关于在 jQuery UI 日期选择器中格式化日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 Angular 2/Typescript 中使用 IScrollUse IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
Anime.js 在 Ionic 3 项目中不起作用anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 项目中不起作用)
Ionic 3 - 使用异步数据更新 ObservableIonic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用异步数据更新 Observable)
Angular 2:在本地 .json 文件中找不到文件Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
在 Ionic 2 中,如何创建使用 Ionic 组件的自定义指In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何创建使用 Ionic 组件的自定义指令?)
将 ViewChild 用于动态元素 - Angular 2 &离子2Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(将 ViewChild 用于动态元素 - Angular 2 amp;离子2)