-5

I have a String variable who represent date

console.log(goDate); --> "23/12/2014"

how I could turn this variable like this..?:

console.log(goDate); --> "2014-12-23".
halfer
  • 19,471
  • 17
  • 87
  • 173
Mercer
  • 9,488
  • 27
  • 98
  • 165

1 Answers1

5
var goDate = "23/12/2014"; // needs 2014-12-23
var newGoDate = goDate.split('/').reverse().join('-');
j08691
  • 197,815
  • 30
  • 248
  • 265