Is there any way to specify input format date.js?

I am using the Date.js library and jQuery. This is my code:

var parsedDate2 = Date.parse(date);
alert(parsedDate2.getTime()/1000);

When I use date:

12/11/2015 08:00 PM 

He sees it as MM/DD/YYYY ...

But when I use the date:

27/11/2015 08:00 PM

He then considers it as DD/MM/YYYY ...which, in fact, is the version that I prefer. So, how can I set the format DD/MM/YYYY ...to use all the time and forget about MM/DD/YYYY ...?

+4
source share
1 answer

The Date.js library you are using is almost a decade old and does not seem to have the latest updates. I would advise you in our place for something like moment.js, which is flourishing and well supported.

.js :

var date = moment( "12/11/2015", "DD-MM-YYYY" );
+4

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


All Articles