Re: Date Expiry of Page using Javascript ?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Date Expiry of Page using Javascript ?

From: alu <none@none.com>
Date: Sat Jul 30 2005 - 04:38:53 CEST

"Dr John Stockton" <jrs@merlyn.demon.co.uk> wrote

> 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) .

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
Received on Tue Oct 18 03:03:40 2005