How to get the current date and time in workflow

Hi - I had to work between UTC and ISO8601 dates in a workflow, and the MomentJS library can actually handle this natively, I think what you want to use is DateTime.utc().toISO(). This will always work regardless of timezone, whereas search/replace will introduce an error if the server time is ever different from the one expected during workflow creation.

Here’s what that looks like given the current time for where I am:

$now(): Wed Oct 25 2023 13:41:13 GMT+1300 (New Zealand Daylight Time)
$now.toISO(): 2023-10-25T13:41:13.403+13:00
Datetime.utc().toISO(): 2023-10-25T00:41:13.403Z

MomentJS Docs for the above: