4

I'm not able to find cause of this behavior

<script>
function myFunction()
{
var d1 = Date.parse("02/11/2014");
var d2 = Date.parse("2014-02-11");
var x = document.getElementById("demo");
x.innerHTML=d1+"---------"+d2+"<br/>"+new Date(d1)+"----"+"<br/>"+new Date(d2);

}
</script>

OUTPUT:

1392057000000---------1392076800000

Tue Feb 11 2014 00:00:00 GMT+0530 (IST)

Tue Feb 11 2014 05:30:00 GMT+0530 (IST)

Why it gives different time when I pass same date in Date.parse() ?

JSBIN shared at: http://jsbin.com/IfufAToX/1/

Piyuesh
  • 1,066
  • 1
  • 9
  • 18

1 Answers1

0

it's all about how you will write the template, I mean

YYYY-MM-DD, or what ever else

Let's take a look what official ecma says: first of all we go here next w go here

hope that helps.

Eugene P.
  • 2,645
  • 19
  • 23
  • I downvoted this at first, but that was a bit too harsh perhaps. Your answer is rather poor compared to the ones in the duplicate, and you didn't really explain it all that well. Linking to the spec is fine, but try to include the essence in your answer here. Links can expire, and a spec can be hard to understand for novice developers. – user247702 Jan 31 '14 at 12:59