Here is my simple code:
function doPost(request) {
var deviceId="JHjdkfjak123214";
var emailId="[email protected]";
var sheet=SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
var rowvals=[];
var formattedDate = Utilities.formatDate(new Date(), "GMT", "dd-MMM-yyyy");
Logger.log(formattedDate);
rowvals.push(deviceId);
rowvals.push(emailId);
rowvals.push(formattedDate);
sheet.appendRow(rowvals);
}
On running this code, the Logger.log shows date like:
29-Jul-2014
But in spreadsheet it gets entered as 7/29/2014. I have changed the format of the cells using the abc button so that all cells of the date column have format dd-MMM-yyyy.
Now when entered manually, the dates appear in the format dd-MMM-yyyy. But when entered by script, again they change to MM/dd/yyyy. Whats the solution for this?