Start a conversation

Adding today's date

If you need to retrieve and display today's date, there are two ways of doing this:

1) Using JavaScript in-built function to get the current date:

var d = new Date();
var datestring = d.getDate() + "-" + (d.getMonth()+1) + "-" + d.getFullYear();
datestring;

Check the calculation in the calculation field helper here.

2) Using the Moment.js library:

var today = moment();
var today_formatted = today.format('DD-MM-YYYY');
today_formatted;

By adjusting the format template between the brackets, it is possible to define how the today's date should be outputted, for example:

  • 'DD-MMM-YYYY' for 13-Aug-2021
  • 'MMM-YYYY' for Aug-2021
  • 'YYYY-MM-DD' for 2021-08-13

Check the calculation in the calculation field helper here.



Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Castor Support Team

  2. Posted
  3. Updated