未来的日期计算 [英] future date calculation

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

问题描述

亲爱的所有人,


我正在尝试制作一个脚本,以星期日格式打印日期

2007年1月14日。日期是显示是下一个星期日

从现在起3周。例如今天是1月7日。这个剧本将于2007年1月28日星期日打印出来。本周所有人都会看到,直到下周日,它将改为2月4日星期日。


我非常坚持从哪里开始,所以你的帮助会被贬低。


问候,


Alex Kemsley

解决方案

alex.kemsley于2007年1月7日在comp.lang.javascript中写道


我正在尝试创建一个脚本,以星期日格式打印日期

2007年1月14日。显示的日期是下一个星期日

从现在起3周。例如今天是1月7日。这个剧本将于2007年1月28日星期日打印出来。本周所有人都会看到,直到下周日,它将改为2月4日星期日。


我非常坚持从哪里开始,所以你的帮助会被贬低。



开头:getDay()

-

Evertjan。

荷兰。

(请在我的电子邮件地址中将x'变为点数)


alex.kemsley说:
< blockquote class =post_quotes>
>
亲爱的所有人,

我正在尝试制作一个脚本,以星期日格式打印日期
2007年1月14日。显示的日期是下一个星期日,从现在起3周后。例如今天是1月7日。该剧本将于2007年1月28日星期日打印出来。本周所有内容都会在下周日之前读到,直到2月4日星期日为止。

我非常坚持从哪里开始,所以你的帮助将是apreciated。



var d = new Date();

d.setDate(d.getDate()+ 21-d.getDay()) ;

提醒(d);


不一定按照你想要的格式化。

-


在comp.lang.javascript消息中< Xn ******************** @ 194.109.133.242>

,Sun,2007年1月7日16:48:39,Evertjan。 < ex ************** @ interxnl.net>

发布:


> alex.kemsley于2007年1月7日在comp.lang.javascript中写道:


>我正在尝试创建一个打印出来的脚本日期格式为星期日2007年1月14日星期日。显示的日期是下一个星期日
3周后。例如今天是1月7日。该剧本将于2007年1月28日星期日打印出来。本周所有内容都会在下周日之前读到,直到2月4日星期日为止。

我非常坚持从哪里开始,所以你的帮助将是apreciated。


开头:getDay()



编号总是先阅读新闻组常见问题解答;见下文。


D =新日期()

X = 0

D.setDate(D.getDate()+ (6 + XD.getDay())%7 +1 + 7 * N)


当初始D从星期六变为太阳时,它会改变值。

OP可能有一个应用程序,其中Weeks运行Sun..Sat,如

祈祷书。但是他的电子邮件地址表明他在一个国家/地区的价格是星期一,星期一,太阳,通常使用的价格为b $ b。


他应该考虑是否代码可以在另一个国家执行,

然后会发生什么。


-

(c)John Stockton ,萨里,英国。 ?@merlyn.demon.co.uk Turnpike v6.05 IE 6

news:comp.lang.javascript FAQ< URL:http://www.jibbering.com/faq/index.html> ;。

< URL:http://www.merlyn.demon.co.uk/js-index.htmjscr数学,日期,来源。

< URL :http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/& c,常见问题项目,链接。


Dear All,

I am trying to make a script that prints a date in the format Sunday
14th January 2007. Where the date that is displayed is the next sunday
3 weeks from now. For example today is 7th January. The script would
print Sunday 28th January 2007. It would read that all of this week
until next sunday when it would change to Sunday 4th February.

I am very stuck on where to start so your help would be apreciated.

Regards,

Alex Kemsley

解决方案

alex.kemsley wrote on 07 jan 2007 in comp.lang.javascript:

I am trying to make a script that prints a date in the format Sunday
14th January 2007. Where the date that is displayed is the next sunday
3 weeks from now. For example today is 7th January. The script would
print Sunday 28th January 2007. It would read that all of this week
until next sunday when it would change to Sunday 4th February.

I am very stuck on where to start so your help would be apreciated.

Start with: getDay()
--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)


alex.kemsley said:

>
Dear All,

I am trying to make a script that prints a date in the format Sunday
14th January 2007. Where the date that is displayed is the next sunday
3 weeks from now. For example today is 7th January. The script would
print Sunday 28th January 2007. It would read that all of this week
until next sunday when it would change to Sunday 4th February.

I am very stuck on where to start so your help would be apreciated.

var d=new Date();
d.setDate(d.getDate()+21-d.getDay());
alert(d);

Not necessarily formated as you want.
--


In comp.lang.javascript message <Xn********************@194.109.133.242>
, Sun, 7 Jan 2007 16:48:39, Evertjan. <ex**************@interxnl.net>
posted:

>alex.kemsley wrote on 07 jan 2007 in comp.lang.javascript:

>I am trying to make a script that prints a date in the format Sunday
14th January 2007. Where the date that is displayed is the next sunday
3 weeks from now. For example today is 7th January. The script would
print Sunday 28th January 2007. It would read that all of this week
until next sunday when it would change to Sunday 4th February.

I am very stuck on where to start so your help would be apreciated.


Start with: getDay()

No. Always start with reading the newsgroup FAQ; see below.

D = new Date()
X = 0
D.setDate(D.getDate()+(6+X-D.getDay())%7 +1 +7*N)

That changes value as the initial D changes from Sat to Sun.

The OP may have an application for which Weeks run Sun..Sat, as in the
Prayer Book. But his E-mail address suggests that he is in a country in
which ISO Weeks, Mon-Sun, are commonly used.

He should consider whether the code may be executed on another country,
and what should then happen.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.


这篇关于未来的日期计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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