[英]Identify date format in jquery and set it as default in a jquery datepicker
// I have installmentDate which is an object object //我有installmentDate,它是一个对象
var installmentDate = installment.installmentDate;
alert(JSON.stringify(installmentDate));
Using JSON.stringify(installmentDate) it shows 使用JSON.stringify(installmentDate)显示
{"date":3, "day":5, "hours":0, "minutes":0, "month":9, "nanos":0, "seconds":0, "time":1412274600000, "timezoneoffset":-330, "year":114}
Please identify in which format this is in. And I am trying to set this date as default to a jquery datepicker These are the following ways I tried and nothing works 请确定它采用的格式。我正在尝试将此日期设置为jquery datepicker的默认值。
$('#dueDate').datepicker('setDate', installmentDate);
$('#dueDate').datepicker('setDate', new Date((installment.installmentDate));
$('#dueDate').val(installmentDate);
Your date does not have the proper format. 您的日期格式不正确。 According to the documentation, here are the possible options:
根据文档,这里是可能的选项:
The new date may be a Date object or a string in the current date format (eg, "01/26/2009"), a number of days from today (eg, +7) or a string of values and periods ("y" for years, "m" for months, "w" for weeks, "d" for days, eg, "+1m +7d"), or null to clear the selected date.
新日期可以是Date对象,也可以是当前日期格式的字符串(例如,“ 01/26/2009”),从今天起的天数(例如,+ 7)或一串值和句点(“ y”代表年份,“ m”代表数月,“ w”代表数周,“ d”代表数天,例如“ + 1m + 7d”),或者为null以清除所选日期。
You might need to reformat your installmentDate
. 您可能需要重新格式化
installmentDate
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.