Jscript约会 [英] Jscript date
本文介绍了Jscript约会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从两个字段(checkindate,chackoutdate)获取格式为27/07/2006的两个日期,我想计算它们之间的天数差异。你能帮忙吗?
Hi,
I get two dates in the format 27/07/2006 from two fields (checkindate,chackoutdate) and I want to calculate the difference in days between them... Can you help?
推荐答案
我认为以下代码解决了你的问题
Hi,
I think the following code solves ur problem
展开 | 选择 | Wrap | 行号
我做了一些修改,脚本产生了以下内容
I have made some modifications and the script resulted to the following
展开 | 选择 | Wrap | 行号
hi,
这是什么^ check_in_date ^
如果是文本框然后将其作为document.formname.check_in_date.value提供
ok
>
hi ,
what is that ^check_in_date^
if it is the textbox then give it as document.formname.check_in_date.value
ok
我做了一些修改,脚本产生了以下内容
< SCRIPT type = text / javascript>
var string = ^ Check_In_Date ^;
var string1 = ^ Check_Out_Date ^;
var day = string.substring(0,2);
var month = string.substring(3,5);
var year = string.substring(6,string.length);
var day 1 = string1.substring(0,2);
var month1 = string1.substring(3,5);
var year1 = string1.substring(6,string。长度);
var startingdate = new日期(年,月-1,日);
alert(startdate);
var finishingdate = new Date(year1,month1-1,day1);
alert(finishdate);
var one_day = 1000 * 60 * 60 * 24;
var result = Math.floor((finishdate。的getTime() - startingdate.getTime())/(one_day));
document.write(结果);
< / SCRIPT>
当我运行它时,我收到以下消息。 。
对象不支持此属性或方法
I have made some modifications and the script resulted to the following
<SCRIPT type=text/javascript>
var string=^Check_In_Date^;
var string1=^Check_Out_Date^;
var day=string.substring(0,2);
var month=string.substring(3,5);
var year=string.substring(6,string.length);
var day1=string1.substring(0,2);
var month1=string1.substring(3,5);
var year1=string1.substring(6,string.length);
var startingdate=new Date(year,month-1,day);
alert(startingdate);
var finishingdate=new Date(year1,month1-1,day1);
alert(finishingdate);
var one_day=1000*60*60*24 ;
var result=Math.floor((finishingdate.getTime()-startingdate.getTime())/(one_day));
document.write(result);
</SCRIPT>
When i run it I get the following message..
Object does not support this property or method
这篇关于Jscript约会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文