Format dates in VBCS page using functions

You can use oj-input-date or oj-input-date-time components for showing formatted date and use convertor options

But when using above component only for read-only purpose to show some values in grid or table, it doesn’t make sense to use input fields.

Instead we can use oj-bind-text field and pass data using following JavaScript function.

The JavaScript function will add necessary formatting to the date and return the value as string.

Live code preview

We can use date convertor functions to format the date in required format

JavaScript function

define(["ojs/ojconverter-datetime"], (datetimeConverter) => {
  "use strict";

  class PageModule {
    convertDateToStr(customDate) {
        let dateConvertor = new datetimeConverter.IntlDateTimeConverter({
          pattern: "dd-MMM-yyyy",
      return dateConvertor.format(customDate);

  return PageModule;

Patterns examples

Patterns Input – date stringOutput – formatted date
MM/dd/yyyy hh:mm:ss2024-01-18T13:59:23+05:3001/18/2024 01:59:23
MM/dd/yyyy hh:mm:ss a2024-01-18T13:59:23+05:3001/18/2024 01:59:23 PM

References –

jsDoc for IntlDateTimeConverter ( to view all convertor options )

Live application URL ( to try out few configs )

1 thought on “Format dates in VBCS page using functions”

Comments are closed.