0

How in JS can I convert this:

var today = "2014-8-20";

to this:

var today = "Wed Aug 20 2014 00:00:00 GMT-0400 (EDT)";

2 Answers2

2
var today = "2014-8-20";
today = new Date(today).toString();
//Wed Aug 20 2014 00:00:00 GMT-0400 (EDT)";

But if you need anything more sophisticated I recommend moment.js

Plato
  • 10,812
  • 2
  • 41
  • 61
0

var today = "2014-8-20"; console.log(new Date(today));

sunny_side_of_life
  • 149
  • 1
  • 3
  • 15