-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,824
  • 17
  • 99
  • 186
Mercer
  • 9,736
  • 30
  • 105
  • 170

1 Answers1

5
var goDate = "23/12/2014"; // needs 2014-12-23
var newGoDate = goDate.split('/').reverse().join('-');
j08691
  • 204,283
  • 31
  • 260
  • 272