Getting started Community Training Tutorials Documentation APIs, AI & Tools
%dw 2.0
output application/json
---
{
nowCalled: now(),
nowCalledSpecificTimeZone: now() >> "America/New_York"
}
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.
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"
}