Results 1 to 2 of 2
Apr 5, 2007, 22:22 #1
Safari Browser issue with Date Object
I am running a script on a page that tests the current date against the date the user specifies as the date for their entry (Diary Site). If the users entry date is a date greater than the current date they are given an alert that they can only enter a date for the current date or a previous one. Everything operates as it should in IE6 (and above) and Firefox. However, the Safari Browser run on Macs is allowing users to post entries beyond the current date.
Using alerts to test for the location of the issue, I have found that it is in the
new Date(); that is created using the values from the form in Safari.
The line of code giving me the issue is the var formDate = new Date(values): values I assume being the culprit:
In all other browsers I am given:
Day Month Date Year Hrs:Minutes:Seconds GMT as you would expect.
I have run tests to ensure that document.byear.value, bmonth and bday are all being passed correctly and they are (In all Browsers including Safari).
Has anyone else encountered this issue?
Apr 6, 2007, 06:02 #2
- Join Date
- Apr 2006
- 0 Post(s)
- 0 Thread(s)
Strings parsed to Dates are browser and language dependent-
Coerce the inputs to integers, and create the Date as
January is 0, February is 1, and so on.
var m=parseInt(form.byear.value)-1; // if input is not 0 based
var formDate = new Date(y,m,d);