0

hi i am using java script to compare between two dates using date.parse function

var pfrmdt = Date.parse(frmdt);
var ptodt = Date.parse(todt);

                   if(pfrmdt <= ptodt)
                     {
                        return true;
                     }
                     else {


                          focusCtrl.value="";
                          focusCtrl.focus();
                        }

and the date format is dd/mmm/yyyy its working properly in other browsers but not in IE8. when I alerts the value of pfrmdt and ptodt its showing NAN in IE8. any solution?

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
Gans
  • 151
  • 3
  • 17
  • possible duplicate of [Javascript JSON Date parse in IE7/IE8 returns NaN](http://stackoverflow.com/questions/11020658/javascript-json-date-parse-in-ie7-ie8-returns-nan) – elclanrs Oct 07 '13 at 07:37
  • I have already take reference from your suggested ans but its doesnt work for me – Gans Oct 07 '13 at 07:43
  • 1
    There are many other dups, one of these should work http://stackoverflow.com/questions/8098963/javascript-datedatestring-returns-nan-on-specific-server-and-browser, http://stackoverflow.com/questions/13758581/javascript-date-returning-nan-in-ie8, http://stackoverflow.com/questions/15319479/in-ie-8-dates-are-nan-nan-nan, http://stackoverflow.com/questions/12687165/javascript-date-undefined-nan-in-ie8 – elclanrs Oct 07 '13 at 07:45
  • How does your date look like? What is `frmdt` and `todt` value? – elclanrs Oct 07 '13 at 07:46
  • frmdt is 01/Oct/2013 and todt is 02/Oct/2013 both are string – Gans Oct 07 '13 at 07:49
  • Dunno... I don't have IE8 but try http://momentjs.com/, that should work crossbrowser – elclanrs Oct 07 '13 at 07:51
  • or tell me any other solution to compare two dates in javascript – Gans Oct 07 '13 at 08:05

1 Answers1

0

Date.parse() is part of ECMAScript-5. Microsoft browser support is as follows:

  • IE9 Mode, IE10 Mode, and IE11 Mode

References

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265