date

Provides methods for working with dates.

If you are using oxygen.conf.js, date module must be added.

modules: ['web', 'log', 'assert', 'date']

fromNow

Returns a future or a past date

Parameters:

Name

Type

Description

unit

String

Unit type. See http://momentjs.com/docs/#/manipulating/add/

value

Number

Number of minutes/days/months/etc to add or subtract from the current date.

format

String

Format string.

Returns:

String - Date formatted according to the specified format string.

date.now() // 2021-03-04T13:02:38+02:00
date.fromNow('2', 'days') // 2021-03-06T13:02:38+02:00
date.fromNow('2', 'months') // 2021-05-04T13:02:38+03:00
date.fromNow('2', 'years') // 2023-03-04T13:02:38+02:00
var today = date.now('DD/MM/YYYY') // 04/03/2021
log.info('Today: ' + today)
var tomorrow = date.fromNow('1', 'days') // 2021-03-05T14:34:42+02:00
tomorrow = tomorrow.slice(0, 10) // 2021-03-05
log.info('Tomorrow: ' + tomorrow)
tomorrow = tomorrow.split('-').reverse().join('/') // 05/03/2021
log.info('Tomorrow: ' + tomorrow)

now

Returns current date and time

See http://momentjs.com/docs/#/displaying/format/ for supported format strings.

Parameters:

Name

Type

Description

format

String

Format string.

Returns:

String - Date formatted according to the specified format string.

date.now('ddd, hA') // Thu, 12PM
date.now('DD/MM/YYYY') // 04/03/2021
date.now('[Today is] dddd') // Today is Thursday
date.now('dddd, MMMM Do YYYY, h:mm:ss a') // Thursday, March 4th 2021, 12:41:22 pm
Contents
fromNow
now