When I run the script to duplicate sheets with a date is give the tab a long date name Thu Oct 18 2018 00:00:00 GMT-0400 (EDT). I would like it to read in a 10/18/18 format.


Use Utilities.formatDate. Example from the link:

// This formats the date as Greenwich Mean Time in the format
// year-month-dateThour-minute-second.
var formattedDate = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd'T'HH:mm:ss'Z'");
| improve this answer | |

Ruben is correct but to give you the exact format based on your question you would do:

Utilities.formatDate(new Date(), "EST", "MM-dd-yy");

Make a note that new Date() is replaced with your variable. By default that pulls the current date and time, if you have a date value that you want to convert that is where it goes.

Timezones will matter as well:

GMT = Greenwich mean time
EST = Eastern Standard time
PST = Pacific Standard time
PDT = Pacific Dayligt time
and others...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.