Skip to content

Instantly share code, notes, and snippets.

@phillypb
Last active January 16, 2019 18:28
Show Gist options
  • Select an option

  • Save phillypb/5e96388526aa6e5fab5b986ca9d8d1ac to your computer and use it in GitHub Desktop.

Select an option

Save phillypb/5e96388526aa6e5fab5b986ca9d8d1ac to your computer and use it in GitHub Desktop.
function organiseDate() {
// example date string
var messyDate = 'Thu Dec 20 2018 13:12:21 GMT-0000 (GMT)';
// create a new date variable
var newDate = new Date(messyDate);
// format the new date variable as required
var niceDate = Utilities.formatDate(newDate, "GMT", "YYYY_MM_dd");
// log output
Logger.log(niceDate);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment