469,573 Members | 1,642 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,573 developers. It's quick & easy.

Dates, Tomorrow and Next Day

I have a successful script for determining today's date.

Does anyone have anything for determining tomorrow and the next day since it
would have to look at the day of month and month of year?

Thanks in advance.
Jul 20 '05 #1
8 41148
"Smoke" <sm***@xatrium.com> writes:
I have a successful script for determining today's date.
Like
var today = new Date();
?
Does anyone have anything for determining tomorrow and the next day since it
would have to look at the day of month and month of year?


The FAQ gives this link to information on dates:
<URL:http://www.merlyn.demon.co.uk/js-dates.htm>
If it isn't there, it's not worth knowing.

To get the day after today (or after any day), do:

var day = new Date();
day.setDate(day.getDate()+1);

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
I cannot see from the info on your link or from your not below how this
would work. I believe also you answered my question the other week, thanks
again for that. Below is what is working. If today was the 31st of December
2003, how would a script look that would know to automatically know that
tomorrow would be 01012004?

var d = new Date();

var filename = "" + (d.getMonth() + 1) + (d.getDate()) + (d.getFullYear());

var fileextension = ".gif";

var file = filename + fileextension;

document.write("<img src=http://www.website.com/graphics/"+file+"
width='358' height='233' border='0' alt='' >");

the url below is only good for today

http://www.xatrium.com/fishing/today.htm

"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:wu**********@hotpop.com...
"Smoke" <sm***@xatrium.com> writes:
I have a successful script for determining today's date.
Like
var today = new Date();
?
Does anyone have anything for determining tomorrow and the next day since it would have to look at the day of month and month of year?


The FAQ gives this link to information on dates:
<URL:http://www.merlyn.demon.co.uk/js-dates.htm>
If it isn't there, it's not worth knowing.

To get the day after today (or after any day), do:

var day = new Date();
day.setDate(day.getDate()+1);

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:

<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.'

Jul 20 '05 #3
Smoke wrote on 19 nov 2003 in comp.lang.javascript:
I cannot see from the info on your link or from your not below how
this would work.


[please do not underquote on usenet]

Try this:

<SCRIPT>
var myday = new Date(2003,12,31);
alert(myday)
myday.setDate(myday.getDate()+1);
alert(myday)
</SCRIPT>

As you see a day set to 2003-12-32
will be automaticly be stored by .setDate as 2004-01-01.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #4
Evertjan. wrote on 19 Nov 2003:
Smoke wrote on 19 nov 2003 in comp.lang.javascript:
I cannot see from the info on your link or from your not below how
this would work.
[please do not underquote on usenet]

Try this:

<SCRIPT>


Type?
var myday = new Date(2003,12,31);
This isn't correct. Those values will produce a date of Saturday, 31
January 2004. Month ordinals, when used with the getMonth/setMonth
methods, their UTC counterparts, and the Date constructor, are zero
based. The correct assignment is:

var myday = new Date( 2003, 11, 31 );
alert(myday)
myday.setDate(myday.getDate()+1);
alert(myday)
</SCRIPT>

As you see a day set to 2003-12-32
will be automaticly be stored by .setDate as 2004-01-01.


Mike

--
Michael Winter
M.******@blueyonder.co.uk.invalid (remove ".invalid" to reply)
Jul 20 '05 #5
JRS: In article <Xn********************@194.109.133.29>, seen in
news:comp.lang.javascript, Evertjan. <ex**************@interxnl.net>
posted at Wed, 19 Nov 2003 17:45:15 :-
Smoke wrote on 19 nov 2003 in comp.lang.javascript:
I cannot see from the info on your link or from your not below how
this would work.
[please do not underquote on usenet]

^^^^^^^^^^

That word actually means "quote too little". The chief sin is in fact
overquoting. Try "Please do not bottom-quote in News".

As you see a day set to 2003-12-32
will be automaticly be stored by .setDate as 2004-01-01.


OP : see <URL:http://www.merlyn.demon.co.uk/js-date1.htm#FR>, Field
Rollover.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #6
Michael Winter wrote on 19 nov 2003 in comp.lang.javascript:
This isn't correct. Those values will produce a date of Saturday, 31
January 2004. Month ordinals, when used with the getMonth/setMonth
methods, their UTC counterparts, and the Date constructor, are zero
based. The correct assignment is:

var myday = new Date( 2003, 11, 31 );


You are right, my mistake.

The example stil shows the right result changing the 31st
by storing the 1st of next month.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #7
Dr John Stockton wrote on 19 nov 2003 in comp.lang.javascript:
[please do not underquote on usenet]

^^^^^^^^^^

That word actually means "quote too little". The chief sin is in fact
overquoting. Try "Please do not bottom-quote in News".


Right John, the result of posting alsio in Dutch NG's.
As you see a day set to 2003-12-32
will be automaticly be stored by .setDate as 2004-01-01.


You didn't you miss my mistake?
new Date(2003,12,31); // new Date(2003,11,31);

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #8
JRS: In article <Xn******************************@193.38.113.46> , seen
in news:comp.lang.javascript, Michael Winter <M.******@blueyonder.co.uk.
invalid> posted at Wed, 19 Nov 2003 22:39:28 :-
var myday = new Date(2003,12,31);


This isn't correct. Those values will produce a date of Saturday, 31
January 2004. Month ordinals, when used with the getMonth/setMonth
methods, their UTC counterparts, and the Date constructor, are zero
based. The correct assignment is:

var myday = new Date( 2003, 11, 31 );


Yes and no.

If the date is indeed constant, and the numbers are not to be replaced
at a later stage by variables,
var myday = new Date( "2003/12/31" );
is better. It is the same length, the month number is unmistakable, and
it provides an example of ISO-8601 date fields and order (numeric YDM is
never used). A truly enlightened browser would also accept the proper
form "2003-12-31".

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Daniel M. Drucker | last post: by
5 posts views Thread by Paul Mason | last post: by
3 posts views Thread by David | last post: by
9 posts views Thread by deko | last post: by
5 posts views Thread by Elainie | last post: by
4 posts views Thread by ASM | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.