Saturday, 12 January 2019

Convert a string into a date format

The following Google Apps Script code was used to convert the date acquired from an email via 'getDate' into a more suitable format that was used as the filename when saving the email.

For example purposes I have used the date string from an email directly in the code below. Once I create a new date variable I use 'formatDate' to strip out the time and convert it into YYYY_MM_dd so giving me a value of 2018_12_20 in this instance. I use underscores rather than full stops as I hit a problem when converting the file to PDF with full stops - Google drive thought they were part of the extension and so I would end up with a filename of only 2018.12.pdf.

Convert a string into a date format.gs

No comments:

Post a Comment