I am trying to get the date format currently displaying as Monday 25 @ 7:30 PM but I would like it to display showing the relevant suffix i.e. ‘th’ or ‘st’ or ‘nd’ i.e. 4th, 1st, 2nd etc.
I am using the code below but getting the error message “Exception: Invalid argument: date. Should be of type: Date” any ideas? Much apprecitated
function getOrdinal(date) {
var d = new Date(),
suffix = ('th', 'st', 'nd', 'rd')((d > 3 && d < 21) || d % 10 > 3 ? 0 : d % 10);
return Utilities.formatDate(date, Session.getScriptTimeZone(), "d'" + suffix + "MMMM, yyyy");
}