Convert Date Format Without Timezone - Google App Script (Javascript), Google Spreadsheet
I'm working on integration between Google spreadsheet and LINE Message API (BOT) where Google app script is back-end. I get the date-format cell from Google spreadsheet and send t
Solution 1:
If you need colb
to contain the original value (including empty) when the date conversion doesn't work, you can do this:
var value = ss.getSheets()[0].getRange(i+3, 2).getValue();
var colb = (typeof value == "object" && value instanceof Date) ? Utilities.formatDate(value, ss.getSpreadsheetTimeZone(), "dd/MM/YY") : value;
Solution 2:
If cell is empty and you want to use Utilities.formatDate I would do like this:
var colb = " " || Utilities.formatDate(ss.getSheets()[0].getRange(i+3, 2).getValue(), ss.getSpreadsheetTimeZone(), "dd/MM/YY");
So in case there is no value in cell just assign default value " "
Post a Comment for "Convert Date Format Without Timezone - Google App Script (Javascript), Google Spreadsheet"