I generate a PDF file from a sheet of Google (that is populated with Google form) using a script and a template with Google Docs. But doing this I obtain that in google sheets date are in dd/mm/yyyy format while in the final PDF it's like this = Sat Feb 27 2016 00:00:00 GMT+0100 (CET)
The "core" of the script is (for each row of the google sheet)
var copyFile = DriveApp.getFileById(TEMPLATE_ID).makeCopy(FileName);
var copyId = copyFile.getId();
var copyDoc = DocumentApp.openById(copyId);
var copyBody = copyDoc.getActiveSection();
for (;columnIndex < headerRow[0].length; columnIndex++) {
copyBody.replaceText('%' + headerRow[0][columnIndex] + '%', RowData[i][columnIndex])
}
columnIndex = 0;
// Create the PDF file, rename it if required and delete the doc copy
copyDoc.saveAndClose();
var dir = DriveApp.getFoldersByName("PDF FOLDER").next();
var newFile = dir.createFile(copyFile.getAs('application/pdf'));
if (PDF_FILE_NAME !== '') {
newFile.setName(FileName)
copyFile.setTrashed(true)
}
Where (and how) can I control the RowData[i] that are date type in order to obtain the correct format in doc/PDF file? (In the template the substitution with effective value is made with the %date name% instruction)
Thanks Vanni