If you run the codes below and your spreadsheet has a date column, the date format looks like this on the client page: Thu May 23 2013 00:00:00 GMT-0400 (EDT)
I want to format the date to something like this: May 23, 2013
I figure you could do that by changing the line
<td><?= data[i][j] ?></td>
to
<td><?= Utilities.formatDate(new Date(data[i][j]), "GMT-5", "MMM dd, yyyy")data[i][j] ?></td>
...but the problem is that not every data in the array is a date object. How do I check if an object in an array is of a certain type? I would like to determine if the current object is a date object before applying the formatDate function.
Code.gs
function doGet() {
return HtmlService
.createTemplateFromFile('index')
.evaluate();
}
function getData() {
return SpreadsheetApp
.openById('123abc')
.getDataRange()
.getValues();
}
index.html
<? var data = getData(); ?>
<table>
<? for (var i = 0; i < data.length; i++) { ?>
<tr>
<? for (var j = 0; j < data[i].length; j++) { ?>
<td><?= data[i][j] ?></td>
<? } ?>
</tr>
<? } ?>
</table>