By defining states with JSONata, you can easily manipulate dates, so I'll share that method.
Step Functions has supported JSONata since November 2024.
Previously, only JSONPath could be used, so manipulating dates required methods like processing timestamps received from Lambda or EventBridge Scheduler.
https://aws.amazon.com/about-aws/whats-new/2024/11/aws-step-functions-variables-jsonata-transformations/?nc1=h_ls
With JSONata, you can easily manipulate dates using 'Date/Time' functions.
https://docs.jsonata.org/date-time-functions
Sample for getting dates and timestamps
With the following definition, you can get the date and time (UTC) when the state machine was executed and the time of the previous day from when it was executed.
This eliminates the need to create unnecessary Lambda functions and allows for a simpler architecture.
{
"Comment": "Get date",
"StartAt": "Pass",
"States": {
"Pass": {
"Type": "Pass",
"End": true,
"Output": {
"CurrentTime": "{% $now() %}",
"CurrentTimestamp": "{% $toMillis($now()) %}",
"YesterdayDateTime": "{% $fromMillis($toMillis($now()) - 86400000) %}",
"YesterdayTimestamp": "{% $toMillis($now()) - 86400000 %}"
}
}
},
"QueryLanguage": "JSONata"
}
When you execute the above state machine, you can confirm the date and time output as follows.
{
"CurrentTime": "2025-08-28T04:19:50.577Z",
"CurrentTimestamp": 1756354790577,
"YesterdayDateTime": "2025-08-27T04:19:50.577Z",
"YesterdayTimestamp": 1756268390577
}