如何使用JQuery自定义UI获取特定月份和年份的总天数? [英] How can I get the total number of days fr a specific month and year using JQuery custom UI?

查看:99
本文介绍了如何使用JQuery自定义UI获取特定月份和年份的总天数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jquery datepicker定制ui中是否有任何功能,可以通过传递月份名称和年份来获得总天数?

Is there any fnction in the JQuery datepicker custom ui where I can get the total number of days by passing on the month name and year?

推荐答案

只需使用常规Javascript.不需要jQuery.我不确定日期选择器会返回什么,但是如果您可以得到像"2012"这样的年份和像"2"这样的月份:

Just use regular Javascript. No need for jQuery. I'm not sure what the date picker returns but if you can get the year like '2012' and the month like '2':

var year = 2012;
var month = 2;
var days = Math.round(((new Date(year, month))-(new Date(year, month-1)))/86400000);

由于2012年是a年,而2月是2月,因此上述代码天变为29.

Since 2012 is a leap year, and 2 is February the above code days becomes 29.

这篇关于如何使用JQuery自定义UI获取特定月份和年份的总天数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆