Answer the question
In order to leave comments, you need to log in
How to change date format in script?
Hello! There is such a script for sending form responses to mail.
You need to change the date format to (yyyy/MM/dd). Help plz!
Apparently it is necessary to do with the help of "Utilities.formatDate"
function sendFormByEmail(e)
{
// instance of Active Spreadsheet:
var responceSheet = SpreadsheetApp.getActiveSheet();
// number of rows in responce form:
var rows = responceSheet.getLastRow();
// range of dates, e-mails:
var date = responceSheet.getRange(rows, 3, 1, 1);
var email = responceSheet.getRange(rows, 8, 1, 1);
// last sender's name, e-mail::
var emailSender = email.getValue();
var dateSender = date.getValue();
// message subject, body:
var subject = "Test";
var body = "Test " + dateSender;
// send the e-mails:
MailApp.sendEmail(emailSender, subject, body);
}
Answer the question
In order to leave comments, you need to log in
Try
var dateSender = Utilities.formatDate(date.getValue(), "GMT+03", "yyyy/MM/dd");
or
var dateSender = Utilities.formatDate(new Date(date.getValue()), "GMT+03", "yyyy/MM/dd");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question