1
votes

Hello I am new to Google Apps Script and programing in general.

I would like to know if I can create a custom date format for the way a date appears when selected in a DateBox.

I read somewhere to use "Utilities.formatDate()" but I can't seem to get it to work.

This is what I tried: (I used the formating code for the date only as an example. I would rather have something like "MMM-DD-YYYY" or "MMM-YY")

var formattedDate = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd'T'HH:mm:ss'Z'");

var grdProjDates = app.createGrid(3,5).setId('GRDprojDates');
grdProjDates.setWidget(0, 0, app.createLabel('Satrting Date'));
grdProjDates.setWidget(0, 4, app.createDateBox().setId('DateProjEnd')
                                                .setName('DateProjEnd')
                                                .setFormat(formattedDate));
1

1 Answers

2
votes

Use the setFormat option on the datebox itself, e.g.

app.createDateBox().setId("FormDate").setValue(Today).setFormat(UiApp.DateTimeFormat.YEAR_MONTH_WEEKDAY_DAY);

as referenced here.