dimanche 10 juillet 2016

Jquery - New Date() Returns Invalid Date


I'm trying to calculate a difference between 2 days using JQuery. The input fields are the bootstrap datepicker ones.

When I console.log the field values, they give me a date a in the format dd-mm-yyyy

Code:

console.log($("#actie_begin").val());

Logs:

27/06/2016

However when I try to use a new date()(to do the calculations) on it, the variable becomes 'Invalid date'

Code:

var start_date = new Date($("#actie_begin").val());

Logs:

Invalid Date

How can I solve this?


Aucun commentaire:

Enregistrer un commentaire