Change Date Format

simple function to change the format of a date string

by Oliver Kelso

JavaScript

function change(time) {
    var r = time.match(/([0-9]+)\/([0-9]+)\/([0-9]+)/);
    return r[3] + '-' + r[1] + '-' + r[2];
}

var time = change('6/10/2013');

console.log(time);