Returns

Date The current date and time on the server, as a JavaScript Date.

Examples

Returns the current date and time on the server, as a standard JavaScript Date. It is Campaign’s canonical “now”.

The result is an ordinary Date, so every Date method works: .getTime(), .getFullYear(), arithmetic, and so on. To turn it into a string, pass it to 📕 formatDate.

As a general rule, prefer it over new Date(), which reads the raw process clock and can drift from the database and the rest of the platform.

Now

var now = getCurrentDate();
logInfo("Started at " + formatDate(now, "%4Y/%2M/%2D %2H:%2N:%2S"));

Get the current year

var year = getCurrentDate().getFullYear(); // 2026

Date arithmetic

getTime() gives epoch milliseconds; build a new Date from it:

var tenMinutesAgo = new Date(getCurrentDate().getTime() - 10 * 60 * 1000);

Time a block of code

The stock instrumentation pattern — capture before and after:

var t = getCurrentDate().getTime();
// ... work ...
logInfo("Took " + (getCurrentDate().getTime() - t) + " ms");

getCurrentDate vs new Date()

Use getCurrentDate(), not new Date(), for the current moment. getCurrentDate() is the date the server considers current, consistent with the database and with date conditions evaluated on the platform. new Date() is the process wall-clock and may differ — different time zone, or a server whose JVM clock isn’t what your data is timestamped against.

See also

  • 📕 formatDate - Format a date into a string using a Campaign date mask. Opposite of parseTimeStamp.
  • 📕 parseTimeStamp - Parse a Campaign timestamp string into a JavaScript Date, so it can be compared or stored. The inverse of formatDate.