添加六个月到开始日期 [英] Add six months to a start date

查看:102
本文介绍了添加六个月到开始日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



使用Java脚本我正在尝试创建代码,当你在

开始日期时它会自动计算6个月的

考试日期。例如,当我将01/01/04作为发行日期

时,考试日期应自动生成为06/01/04。我会

感谢它,如果有人可以帮助我。


谢谢

Sandy

Hi,
Using Java script I am trying to create code where when you place in
the start date it automatically calculates 6 months for the
experations date. For example when I place 01/01/04 as the issue date
the experation date should automaically generate as 06/01/04. I would
appreciate it if anyone could help me.

Thank you
Sandy

推荐答案

我已经从 sa ******阅读了以下消息****@yahoo.com (沙)

并决定借给我丰富的知识。


作者说:
I have read the following message from sa**********@yahoo.com (sandy)
and have decided to lend my vast knowledge.

The writer said:

使用Java脚本我正在尝试创建代码,当你在
开始日期时,它会自动为
考试日期计算6个月。例如,当我将01/01/04作为发布日期时,考试日期应自动生成为06/01/04。如果有人能帮助我,我会很感激。

谢谢
Sandy
Hi,
Using Java script I am trying to create code where when you place in
the start date it automatically calculates 6 months for the
experations date. For example when I place 01/01/04 as the issue date
the experation date should automaically generate as 06/01/04. I would
appreciate it if anyone could help me.

Thank you
Sandy




我的回复是:

在给出答案之前必须考虑以下事项。如果

的日期是31日,而且六个月之后没有31个呢?


03/31/04之后的六个月是什么时候?

BTW:01/01/04之后的六个月是07/01/04而不是06/01/04。


-

Dennis M. Marks
http:// www。 dcs-chico.com/~denmarks/

用dcsi.net替换domain.invalid

----- =通过Newsfeeds.Com发布,未经审查Usenet News = -----
http://www.newsfeeds.com - 世界排名第一的新闻组服务!

----- ==超过100,000个新闻组--19个不同的服务器! = -----



and my reply is:
The following must be considered before an answer can be given. What if
the date is the 31st and there is no 31st six months later?

What is six months after 03/31/04?

BTW: Six months after 01/01/04 is 07/01/04 not 06/01/04.

--
Dennis M. Marks
http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----


这是一个简单的脚本,可以帮助你入门。


var date = new Date( );

var date6MonthsFromNow = new Date(date.getTime()+(182 * 24 * 60 * 60 * 1000));


公式为简单[当前时间以密尔+为单位(#days在6个月内* #hrs在

天* #mins in hrs * #sec in min * #mils in sec)]

问候

Mike
Here is a simple script that may get you started.

var date = new Date();
var date6MonthsFromNow = new Date(date.getTime() + (182*24*60*60*1000));

the formula is simply [current time in mils + (#days in 6 months * #hrs in
day * #mins in hrs * #sec in min * #mils in sec)]

Regards
Mike


Mike< mi **************** *@synovic.com>写道:
Mike <mi*****************@synovic.com> wrote:
这是一个简单的脚本,可以帮助你入门。

var date = new Date();
var date6MonthsFromNow = new Date (date.getTime()+(182 * 24 * 60 * 60 * 1000));

公式只是[当前时间以密尔+为单位(#days在6个月内* #hrs in the br /> day * #mins in hrs * #sec in min * #mils in sec)]
Here is a simple script that may get you started.

var date = new Date();
var date6MonthsFromNow = new Date(date.getTime() + (182*24*60*60*1000));

the formula is simply [current time in mils + (#days in 6 months * #hrs in
day * #mins in hrs * #sec in min * #mils in sec)]




6个月内的天数直接取决于6个月的跨度你支付

封面。


在可以覆盖的12个6个月跨度中,只有2个有182天:


Jan-Jun 181天

2月 - 7月181天

3月 - 8月184天

4月 - 9月183天

5月 - 10月184天

6月 - 11月183天

7月 - 12月184天

8月 - 1月184天

9月 - 2月181天

10月 - 3月182天

11月至4月181天

12月 - 5月182日


意味着你的脚本只有1/6(或约17%的时间),而不是什么

我认为非常有效。


这并没有考虑每4年的闰日,这是一个

自己的问题,并介绍了6种可能性:


2月 - 7月182天

3月 - 8月185天

4月-Sep 184天

5月 - 10月185天

6月 - 11月184天

7月 - 12月185天

8月 - 1月185天


但你的正确率仍然是1/6。


-

兰迪



How many days are in 6 months depends directly on what 6 month span you
cover.

Of the 12 6 month spans that can be covered, only 2 have 182 days:

Jan-Jun 181 days
Feb-July 181 days
Mar-Aug 184 days
Apr-Sep 183 days
May-Oct 184 days
Jun-Nov 183 days
July-Dec 184 days
Aug-Jan 184 days
Sep-Feb 181 days
Oct-Mar 182 days
Nov-Apr 181 days
Dec-May 182 days

Means that your script is only right 1/6 (or ~17% of the time), not what
I would consider very efficient.

And that does not take into account leap day every 4 years, which is a
problem of its own and introduces 6 more possibilities:

Feb-July 182 days
Mar-Aug 185 days
Apr-Sep 184 days
May-Oct 185 days
Jun-Nov 184 days
July-Dec 185 days
Aug-Jan 185 days

but your correctness ratio is still 1/6.

--
Randy


这篇关于添加六个月到开始日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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