DataWeave 2.2 is compatible and bundled with Mule 4.2. Standard Support for Mule 4.2 ended on May 2, 2021, and this version of Mule will reach its End of Life on May 2, 2023, when Extended Support ends.

Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted.

MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements.

now(): DateTime

Returns a DateTime value for the current date and time.


This example uses now() to return the current date and time as a DateTime value. It also shows how to return a date and time in a specific time zone. Java 8 time zones are supported.


%dw 2.0
output application/json
   nowCalled: now(),
   nowCalledSpecificTimeZone: now() >> "America/New_York"


  "nowCalled": "2019-08-26T13:32:10.64-07:00",
  "nowCalledSpecificTimeZone": "2019-08-26T16:32:10.643-04:00"


This example shows uses of the now() function with valid selectors. It also shows how to get the epoch time with now() as Number. For additional examples, see Date and Time (dw::Core Types).


%dw 2.0
output application/json
  now: now(),
  epochTime : now() as Number,
  nanoseconds: now().nanoseconds,
  milliseconds: now().milliseconds,
  seconds: now().seconds,
  minutes: now().minutes,
  hour: now().hour,
  day: now().day,
  month: now().month,
  year: now().year,
  quarter: now().quarter,
  dayOfWeek: now().dayOfWeek,
  dayOfYear: now().dayOfYear,
  offsetSeconds: now().offsetSeconds,
  formattedDate: now() as String {format: "y-MM-dd"},
  formattedTime: now() as String {format: "hh:m:s"}


  "now": "2019-06-18T16:55:46.678-07:00",
  "epochTime": 1560902146,
  "nanoseconds": 678000000,
  "milliseconds": 678,
  "seconds": 46,
  "minutes": 55,
  "hour": 16,
  "day": 18,
  "month": 6,
  "year": 2019,
  "quarter": 2,
  "dayOfWeek": 2,
  "dayOfYear": 169,
  "offsetSeconds": -25200,
  "formattedDate": "2019-06-18",
  "formattedTime": "04:55:46"

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub