date problems in javascript[resolved]
Hmm, here's a thing.
I have a date which is passed in a form (dd/mm/yyyy). I need to compare this to today's date using javascript.
Code:
<script language="javascript">
function somefunction()
{
var renewdate = document.frm.renewdate.value;
var today = new Date()
renewdte = Date.parse(renewdate)
todaysdte = Date.parse(today)
thedate = today.getDay();
if (renewdte < todaysdte)
{
alert("The date of your renewal has passed");
return false;
}
}
</script>
Now, this works on my development machine but not on my live web server. I have
Code:
<%setLocale(2057)%>
In the page that contains the form but the live web server is taking the renewal date 01/10/2005 in the US format 10/01/2005.
And it's proper doing my head in!
Any clues?
Re: date problems in javascript
Something has occurred to me. I think if I could coerce the form field 'renewdate' into a javascript Date object then I should be able to manipulate it that way but I've tried:
Code:
var day = renewdate.substr(0,2)
var month = renewdate.substr(3,2)
var year = renewdate.substr(6,4)
var whenever = new Date(year,month,day)
alert(whenever);
But this returns:
Tue Nov......oh, hang on! I've cracked it!
Hooray (runs round office, arms aloft....like a loser)....
:afrog: