Date and time formatter for javascript. Based on ruleset established in the service www.oslo.kommune.no.

Use numbers for date and time in lists and if unsure. Text (name of day and/or month) is used when in combination with other text (paragraphs).

Important

Remember that in JS months are zero based, so January is 0 and December is 11.

OdsDateFormat.format(dateFrom, dateTo, dateFromOptions, dateToOptions);

The arguments are:

  • dateFrom

    Date object. Required.

  • dateTo

    Date object. Optional. Default null.

  • dateFromOptions

    Object. Optional. Default {}.

  • dateToOptions

    Object. Optional. Default {}.

The options are:

  • format

    The format of the string. Default is date, supported options are date, time, datetime, daytime, custom.

  • locale

    The locale of the string. Default is no-NO, tested options are no-NO, en-GB.

  • prefix

    The prefix of the string. Default is "".

  • suffix

    The suffix of the string. Default is "".

  • time.prefix

    The prefix of the time when used in combination with date. Default is "".

  • localeOptions

    Available options. Defaults are hourCycle: "h24", calendar: "gregory", timeZone: "Europe/Oslo"