If you are using oxygen.conf.js, date module must be added.
modules: ['web', 'log', 'assert', 'date']
Returns a future or a past date
Parameters:
Name | Type | Description |
|
| Unit type. See http://momentjs.com/docs/#/manipulating/add/​ |
|
| Number of minutes/days/months/etc to add or subtract from the current date. |
|
| 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/2021log.info('Today: ' + today)​var tomorrow = date.fromNow('1', 'days') // 2021-03-05T14:34:42+02:00tomorrow = tomorrow.slice(0, 10) // 2021-03-05log.info('Tomorrow: ' + tomorrow)​tomorrow = tomorrow.split('-').reverse().join('/') // 05/03/2021log.info('Tomorrow: ' + tomorrow)
Returns current date and time
See http://momentjs.com/docs/#/displaying/format/ for supported format strings.
Parameters:
Name | Type | Description |
|
| 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