Hi Grace,
Welcome to the Google Ads Scripts forum channel.
Upon checking, it appears that the "yyyyMMdd" format produces an invalid date. I suggest you check this link (https://developers.google.com/google-ads/scripts/docs/features/dates) to learn more on how to work with dates and times in Google Ads Scripts. Based on the "Creating a date object from a formatted date string" section of the link I provided, the date constructor can only parse certain date string formats. To make sure your date string is parsed correctly, always provide it in the MMMM dd, yyyy HH:mm:ss Z format.
![]() |
Google Ads Scripts Team |
Hi Grace,
Thanks for getting back.
Upon further investigation, it appears that the issue is due to having created a date object, passing that within the format, and then passing those again into a new date object. I would recommend going through the documentation <https://developers.google.com/google-ads/scripts/docs/features/dates#basic_concepts> our team previously provided as it also shows an example on creating a date object and logging it formatted. I would suggest just passing the formatted date object to a variable and logging that without passing it to a new date object. You could refer to the snippet of code below which should output to a yyyyMMdd format:
var now = new Date();
var timeZone = AdsApp.currentAccount().getTimeZone();
var dateString = Utilities.formatDate(now, timeZone, 'yyyyMMdd');
Logger.log("Today's date is " + dateString); // yyyyMMdd format
If this is not what you're looking for, kindly provide the following information and elaborate on your use-case so we're able to further investigate and guide you accordingly: