1

The IE9 debugger (F12 developer tools -> script debugger) shows the following in the Locals window when I step through the code when the page is launched from the server:

 midnight  Fri Mar 15 00:00:00 EDT 2013      Object, (Date) 
 myDate    Fri Mar 15 00:00:00 EDT 2013      Object, (Date)  

and yet the following conditional test for equality of value resolves to false:

 if (midnight.valueOf() === myDate.valueOf() ) {
    // these lines of code are never reached
     .
     .
     .
 }

The odd thing, the === test resolves to true on my development PC. I cannot figure out why it resolves to false on the page served up by the server. The debugger clearly indicates it should resolve to true.

The document is in "IE9 Standards" mode.

Tim
  • 8,669
  • 31
  • 105
  • 183

1 Answers1

2

The valueOf method returns the primitive value of a Date object as a number data type, the number of milliseconds since midnight 01 January, 1970 UTC.

The debugger only shows you the seconds so the variables may actually be different.

laktak
  • 57,064
  • 17
  • 134
  • 164
  • Should probably be a comment (the question/issue is currently vague), although it contains a clue: what *are* the actual epoch offsets? –  Mar 15 '13 at 21:33
  • @pst: chris pointed me in correct direction. When the dates were instantiated, they were instantiated: `var d = new Date(); d.setHours(0); d.setMinutes(0); d.setSeconds(0)`. Now I've added `d.setMillseconds(0)`. – Tim Mar 15 '13 at 21:37