Todays date Velocity scripting

Good morning all,
I am trying to import todays date as a static and failing.
I’ve tried variations on all of the below, but to no avail.
Has anyone got a working version of getting todays date.

"value": "#set($myDate = $dateTool.getDate())$myDate"
"value": "#set($myDate = $date.get('long')$myDate"
"value": "#set($myDate = $date)$myDate"
"value": "#set($myDate = $tools.dateTool)$date.format('dd-MM-yyyy', $myDate)"

Many thanks
Phil

Hi @phil_awlings,

Can you try this ?

"value": "#set($currentDate = $dateTool.format('yyyy-MM-dd', $dateTool.now()))$currentDate"

@phil_awlings after testing velocity script that i give above, it doesn’t work.

I don’t know what’s exactly your use case but you can use the following transform to get current date or today formated as you want :

{
      "name": "Current date Format Transform ",
           "type": "dateFormat",
            "attributes": {
                "input": {
                    "attributes": {
                        "expression": "now"
                    },
                    "type": "dateMath"
                },
                "inputFormat": "yyyy-MM-dd",
                "outputFormat": "yyyy-MM-dd"
            }
}

Result :

this is just an example of testing result

3 Likes

The velocity scripting didn’t work for me either, but using Date format does.
I got so stuck with velocity that I didn’t think about other solutions.

Thank you
Phil

PS. The use case is that the client wants to enable a time frame when guest users can access the system, so I need to toggle the lifecycle by time. Therefore I need to concatenate todays date with the on/off time details. Its probably going to be clunky, but it will work

The date format transform does respond your use case, right ?

Yes it does.
Thanks again

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.