Dario Calovic Dario Calovic - 1 year ago 126
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

Answer Source

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>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download