I am trying to format the date in the popup on the map in ArcGIS for Javascript using the online documentation
Consider the following code:
I can't seem to get the fieldInfos format to format the date. The date keeps coming out in the default format:
Any ideas to what is causing the issue?
for reference here are my dependencies:
I would recommend simply switching the content property to a function like this:
const popup = new PopupTemplate( {
title: "Project: <a href=\"http://pr/profile.aspx?pid={projectNumber}\" target=\"_blank\" >{projectName}</a>",
content: ({graphic}) => {
const { startDate, endDate } = graphic.attributes;
const start = `${startDate.getFullYear()}-${startDate.getMonth()}-${startDate.getDate()}`;
const end = `${endDate.getFullYear()}-${endDate.getMonth()}-${endDate.getDate()}`;return `<p><b>Start Date:</b> ${start} <b>End Date</b>: ${end}<p>`;
}
});
I find it much easier to just create my own custom function for adjusting the field values instead of using the fieldInfos objects.