0

I need to convert this date format : Fri Jul 29 2016 00:00:00 GMT+0100 (Maroc (heure d’été)) (I don't what do we call it by the way ) to iso format (yyyy-mm-dd 00:00:00.000 ) using javascript Thanks in advance

1
  • Possible duplicate of Formatting ISODate from Mongodb. The Mogodb part of the linked question is irrelevant. The solution is the same. Commented Jul 11, 2016 at 11:07

2 Answers 2

1

Here is sample snippet for your query. I hope it helps for your query.

 function formatDate(date) { var d = new Date("Fri Jul 29 2016 00:00:00 GMT+0100"), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; return [year, month, day].join('-'); } 
Sign up to request clarification or add additional context in comments.

Comments

1

Using moment.js:

moment(new Date("Fri Jul 29 2016 00:00:00 GMT+0100")).format("Y-MM-DD HH:mm:ss.SSS") 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.