Dario Calovic Dario Calovic - 5 months ago 59
Javascript Question

Given string format to date

I have given a very unusual date format in

. I need to convert it to a JS date object and add up a few days. The last step is clear, but I don't know how to convert the string into the JS date object. Take a look at the string date:
October 02, 2016


You should use moment.js


moment(dateString, format, locale)

var dateStr = "Oktober 02, 2016"
var d = moment(dateStr, "MMM DD, YYYY", 'de');
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment-with-locales.min.js"></script>