JRS: In article <%urGe.6039$d02.844466@news20.bellglobal.com>, dated
Fri, 29 Jul 2005 10:58:38, seen in news:comp.lang.javascript, alu
<none@none.com> posted :
><ianv2@aol.com> wrote in message
>> If my questionnaireform.html page had an expiry date of July 31, if I
>> tried to access that page after this date (i.e. August 1st) I would be
>> redirected to index.html.
>>
>> Is this possible?
>quickly modified from Don Demrow's script at
>http://javascript.internet.com/calendars/auto-expire.html
>// Set the expiry date below
>var expireDate = "20050731";
[quoted text clipped - 18 lines]
>
>if (GMTdate > expireDate) {location.href = "index.html"}
Bloatware. All that is needed is
if (new Date() > new Date("2005/07/31")) location.href = "index.html"
If the expiry date is computed, just set it in a Date Object and put
that after the comparison operator.
If the expiry date is to be UTC, add " UTC" to the string, or use
new Date(2005, 7-1, 31) .
Here the expiry date should be the first non-allowed date; one could use
new Date(2005, 7-1, 31+1) .

Signature
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
alu - 30 Jul 2005 03:38 GMT
> Bloatware. All that is needed is
>
[quoted text clipped - 8 lines]
> Here the expiry date should be the first non-allowed date; one could use
> new Date(2005, 7-1, 31+1) .
Thanks John, 'knew it was fat....was even fatter before.
Question - while I was checking the original code in Firefox,
var nowDate = new Date();
var year = nowDate.getYear();
year returned '105', while in IE, year returned '2005'.
Can you explain?
Changing the line to: var year = nowDate.getUTCFullYear()
cleared up the discrepancy.
-alu
Dr John Stockton - 30 Jul 2005 22:29 GMT
JRS: In article <vLBGe.6277$d02.925568@news20.bellglobal.com>, dated
Fri, 29 Jul 2005 22:38:53, seen in news:comp.lang.javascript, alu
<none@none.com> posted :
>var nowDate = new Date();
>var year = nowDate.getYear();
>
>year returned '105', while in IE, year returned '2005'.
>Can you explain?
Mere idiocy on the part of early implementers of javascript, back in the
1900's and not expecting the 2000's.
Since they were accustomed to writing the year with two digits (which is
moderately unambiguous between the 31st year of a century and the last),
they provided a primitive for a two-digit year number and none for a
proper year number. Naturally, they implemented different behaviours
for after the year '99. Some made the next year 0, some 100, some 2000.
My Web page js-date0.htm refers.
Perfectly stupid : it would have been much simpler to give the full year
in the first place, and it can so readily be converted to two digits if
desired either by using %100 or by substringing. I have a routine, BTW,
for determining the full year in browsers that lack the full year
functions - getFY(), in my js-date0.htm.

Signature
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.