|
-
Sep 22nd, 2005, 07:07 AM
#1
Thread Starter
Hyperactive Member
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?
Last edited by thebloke; Sep 22nd, 2005 at 10:02 AM.
Reason: resolved
The Bloke
www.blokeinthekitchen.com
making cooking cool for blokes
-
Sep 22nd, 2005, 10:00 AM
#2
Thread Starter
Hyperactive Member
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)....
The Bloke
www.blokeinthekitchen.com
making cooking cool for blokes
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|