日期比较90天内? [英] date compare within 90days?

查看:205
本文介绍了日期比较90天内?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个功能,我需要检查传入的日期是今天90天内的
。有人可以帮助我让这个工作,我怎么办?与今天相比,90天的


< script language =''javascript''>

函数CheckDate(productDate)

{

var dateVar = new Date(productDate);

// alert(dateVar) );

var today = new Date();

// alert(今天);

alert(today.getDate() - dateVar .getDate());

}

< / script>


我正在减去日期,尝试定时,但不能弄清楚它是什么'

返回。

解决方案

所以****** @ yahoo.com


我有一个功能我需要检查传递的日期是否在今天90天内的
。有人可以帮助我让这个工作,我怎么办?与今天相比,90天的


< script language =''javascript''>

函数CheckDate(productDate)

{

var dateVar = new Date(productDate);

// alert(dateVar) );

var today = new Date();

// alert(今天);

alert(today.getDate() - dateVar .getDate());

}

< / script>


我正在减去日期,尝试定时,但不能弄清楚是什么回来了。



毫秒?

除以86 400 000(一天内的毫秒数)。

汤姆


so******@yahoo.com


我有一个功能,我需要检查传入的日期是今天90天内的



解析错误。你在谈论90天或3个月左右?之前或

从今天开始?


有人可以帮助我开始工作,我该怎么做

90天与今天比较?

< script language =''javascript''>



< script type =" text / javascript">


function CheckDate(productDate)

{

var dateVar = new Date(productDate);

// alert(dateVar);

var today = new Date();

// alert(今天);

alert(today.getDate() - dateVar.getDate());

}

< / script>


我正在减去日期,



错误的方法。


尝试定时,



Pardon?


但不能弄清楚它返回的是什么。



* *被评估为*日期之间的毫秒数,

其提供的关闭为-3'' 600''000毫秒(标准到DST)

或+ 3''600''000毫秒(DST到标准)如果DST切换发生在

之间。因此,减法是错误的方法。


var now = new Date(),later = new Date(),before = new Date();

//从现在开始90天

later.setDate(now.getDate()+ 90);


// 90天前

before.setDate(now.getDate() - 90);


您可以将设定日期与任何给定日期进行比较。


如果你的意思是几个月,分别使用getMonth()和setMonth()。

HTH


PointedEars

-

任何拍下这个页面的人最好用浏览器X查看标签

a网页似乎对过去的糟糕日子感到满意,在网络之前,当你几乎没有机会阅读另一台计算机,另一台文字处理器或其他网络上写的文件时,你需要支付b $ b。 - Tim Berners-Lee


Tom de Neef写道:

所以****** @ yahoo.com


> [...]
alert(today.getDate() - dateVar.getDate());
}
< / script>

我正在减去日期,尝试定时,但是无法弄清楚它是什么回来了。



毫秒?



或多或少。


除以86 400 000(一天内的毫秒数)。



在他们取消DST并且实现具有

时,他们不会正常工作。

PointedEars

-

var bugRiddenCrashPronePieceOfJunk =(

navigator.userAgent.indexOf(''MSIE 5'')!= -1

&& navigator.userAgent.indexOf(''Mac'')!= -1

)// Plone,register_function.js:16


Hi,
I have a function where i need to check the date passed in is within
90days of today. Could someone help me get this to work, how do i do
the 90 days compare with today?
<script language=''javascript''>
function CheckDate(productDate)
{
var dateVar = new Date(productDate);
//alert(dateVar);
var today = new Date();
//alert(today);
alert( today.getDate()-dateVar.getDate() );
}
</script>

I''m subtracting the date, tried timed, but can''t figure out what''s it
returning.

解决方案

so******@yahoo.com:

I have a function where i need to check the date passed in is within
90days of today. Could someone help me get this to work, how do i do
the 90 days compare with today?
<script language=''javascript''>
function CheckDate(productDate)
{
var dateVar = new Date(productDate);
//alert(dateVar);
var today = new Date();
//alert(today);
alert( today.getDate()-dateVar.getDate() );
}
</script>

I''m subtracting the date, tried timed, but can''t figure out what''s it
returning.

miliseconds ?
divide by 86 400 000 (nr of miliseconds in a day).
Tom


so******@yahoo.com wrote:

I have a function where i need to check the date passed in is within
90days of today.

Parse error. Are you talking about 90 days or about 3 months? Before or
since today?

Could someone help me get this to work, how do i do
the 90 days compare with today?
<script language=''javascript''>

<script type="text/javascript">

function CheckDate(productDate)
{
var dateVar = new Date(productDate);
//alert(dateVar);
var today = new Date();
//alert(today);
alert( today.getDate()-dateVar.getDate() );
}
</script>

I''m subtracting the date,

Wrong aproach.

tried timed,

Pardon?

but can''t figure out what''s it returning.

It *is evaluated to* the number of milliseconds between the dates, with
the provision of its being off by -3''600''000 milliseconds (standard to DST)
or +3''600''000 milliseconds (DST to standard) if DST switching occurs in
between. Therefore, subtraction is the wrong approach here.

var now = new Date(), later = new Date(), before = new Date();

// 90 days from now
later.setDate(now.getDate() + 90);

// 90 days ago
before.setDate(now.getDate() - 90);

You can compare the set date with any given date then.

If you mean months, use getMonth() and setMonth(), respectively.
HTH

PointedEars
--
Anyone who slaps a ''this page is best viewed with Browser X'' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee


Tom de Neef wrote:

so******@yahoo.com:

>[...]
alert( today.getDate()-dateVar.getDate() );
}
</script>

I''m subtracting the date, tried timed, but can''t figure out what''s it
returning.


miliseconds ?

More or less.

divide by 86 400 000 (nr of miliseconds in a day).

Won''t work precisely until they have abolished DST and implementations have
taken that into account.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf(''MSIE 5'') != -1
&& navigator.userAgent.indexOf(''Mac'') != -1
) // Plone, register_function.js:16


这篇关于日期比较90天内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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