用javascript查找天数 [英] find no of days by javascript

查看:114
本文介绍了用javascript查找天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有日期和时间
不需要从javascript中找日子?
例如,2010年3月30日至2010年2月4日

基本上

I have from date and to date
need to find no days from javascript??
e.g 30-3-2010 to 2-4-2010 like this

basically

using gridview in asp.net with c#

three are 2 cols from date and to date where user can select the date??

I need to find no of days by javascript by onblur method ???


进行计算


to calculate it

推荐答案

在此处查找js代码

Find js code here

function DateDifference(date1, date2){
var day=1000*60*60*24;
//Calculate difference btw the two dates, and convert to days
return (Math.ceil((date1-date2)/day));
}



只是您需要在此方法中传递日期,这将返回您的天差.



Just you need pass your dates in this method and it will return you days difference.


看起来Javascript没有提供时间跨度对象,因此您必须编写自己的功能.应该不会太困难,您的麻烦是什么?
:)
It looks like Javascript doesn''t provide a timespan object, hence you have to write your own function. It shouldn''t be too difficult, what is your trouble about?
:)


这篇关于用javascript查找天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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