Fixing date format in JS for IE and Safari