Getting date object from jquery ui datepicker maxDate option

放肆的年华 提交于 2019-12-01 07:06:37

问题


By using the following

var maxDate = $( ".selector" ).datepicker( "option", "maxDate" );

The output can be anything from '+1M','+20Y', '12/12/2013' or more..

Are the '+1M' & '+20Y' examples something that can be used with native javascript to add to the current date so I'd be able to get an actual date object?

I would like to use this to validate the following function that is used by a set of presets (Current Week, Month, Day etc)

function SetDate(dateFrom, dateTo) {
        $('.dateFrom').attr('value', dateFrom);
        $('.dateTo').attr('value', dateTo);
    }

Reference


回答1:


After a bit more searching I found this answer to "jQuery datepicker getMinDate '+1d'"

I decided to use the second example the user posted:

var minDateAttr = $(elem).datepicker("option", "minDate");
var inst = $(elem).data("datepicker");
var minDateObj = $.datepicker._determineDate(inst, minDateAttr, new Date());


来源:https://stackoverflow.com/questions/15618135/getting-date-object-from-jquery-ui-datepicker-maxdate-option

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!