Javascript date format issue

I can not find the reason for 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>

EXIT:

1392057000000 --------- 1392076800000

Tuesday February 11, 2014 00:00:00 GMT + 0530 (IST)

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

Why does this give a different time when I pass the same date to Date.parse ()?

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

+4
source share
1 answer

all about how you write a template i mean

YYYY-MM-DD, or what else

Let's see what the official ecma says: first of all, we go here next w go here

hope this helps.

0
source

Source: https://habr.com/ru/post/1524697/


All Articles