JavaScript clone of MySQL's DATE_FORMAT() function