从 jquery datepicker 获取今天的日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12428203/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Get today's date from jquery datepicker
提问by Hazem Salama
I need to change the default display of currentText
property in jquery datepicker from "Today" to "Today: Septmeber 14, 2012". So the question is does the datepicker expose today's date via some method? or do I have to create my own JS new Date() and get the date from there, which I am trying to avoid!
我需要将currentText
jquery datepicker中属性的默认显示从“今天”更改为“今天:2012 年 9 月 14 日”。所以问题是日期选择器是否通过某种方法公开今天的日期?或者我是否必须创建自己的 JS new Date() 并从那里获取日期,这是我试图避免的!
$('#txtSelectedDate').datepicker({
showButtonPanel: true,
currentText: "Today: " + getTodaysDate(); // Is there such a method?
});
回答by Michal Klouda
回答by ThierryB
If you need to initialize the datepicker with current date, you could use:
如果您需要使用当前日期初始化日期选择器,您可以使用:
$(".selector").datepicker( "option", "gotoCurrent", true );
And of course you have the dateFormat
which take a format defined here
当然,你有dateFormat
哪些需要在这里定义的格式
回答by Moses Villamor
If you need to initialize the datepicker with current date, you could use:
如果您需要使用当前日期初始化日期选择器,您可以使用:
$(".selector").datepicker( "option", "gotoCurrent", true );