I have managed to write code to get the google spreadsheet data in JSON format. When I test the code in the script editor the dates show correctly but when I deployed and tested the link in postman.co all dates are one day behind. I mean it shows 31-Dec-2022 for 01-Jan-23, 01-Jan-23 for 02-Jan-23 and so on (one day earlier). I do not have time in the spreadsheet, by the way. How can I fix it?
Following is the script
function doGet(e) {
var records = {};
var rows = sheet.getRange(2, 1, sheet.getLastRow()-1, sheet.getLastColumn()).getValues();
data = [];
for (var r = 0, l = rows.length; r < l; r++) {
var row = rows[r], record = {};
record['Date'] = row[0];
record['Branch'] = row[1];
record['NetSale'] = row[2];
record['Profit'] = row[3];
data.push(record);
}
records.items = data;
// Logger.log(records)
var result = JSON.stringify(records);
return ContentService.createTextOutput(result).setMimeType(ContentService.MimeType.JSON);
}
Following is the screenshot of the Date column in the spreadsheet.