Gravatar for

Question by Arulselvan, Dec 7, 2017 8:40 PM

Modify Date format in result view

Requirement is to change date format in the result. Below hightlighted date format needs to be changed to "13 November 2017". kindly suggest on this. Thanks in

2 Replies
Gravatar for

Answer by Jean-François L'Heureux, Dec 7, 2017 10:38 PM

Depending on the version of JS UI you are using, you can either use:

`Globalize.format(Coveo.DateUtils.convertToStandardDate(1512680420000), 'd MMMM yyyy')`


`Globalize.format(Coveo.DateUtils.convertFromJsonDateIfNeeded(raw.sysdate), 'd MMMM yyyy')`

See for more information

Gravatar for

Comment by Arulselvan, Dec 7, 2017 11:30 PM

I have tried the above code,




Wed Nov 15 2017 13:13:05 GMT-0500 (Eastern Standard Time)


<a>{{-Globalize.format(-Coveo.DateUtils.convertFromJsonDateIfNeeded(raw.sysdate), 'd MMMM yyyy')}}</a>



Am i missing anything here?

Thanks in advance.

Gravatar for

Comment by Arulselvan, Dec 7, 2017 11:52 PM

= Globalize.format(Coveo.DateUtils.convertFromJsonDateIfNeeded(raw.sysdate), 'd MMM yyyy')

I missed "=". Thank a lot for your help.

Gravatar for

Answer by François Lachance-Guillemette, Dec 8, 2017 3:12 PM

In the result templates , there are many Helpers, like the `date()` method which accepts a `Date` object and you can see the second option, which is a DateToStringOptions.

The `predefinedFormat` attribute is what you need:

dateTime(raw.sysdate, { predefinedFormat: "yyyy-MM-D" })



Ask a question