Date formatting
@DateTime I format <valueRef> from "<source-format>" to "<target-format>" as <name>
Converts the given date/time value to another format and stores the result in the given name in the global scope.
@DateTime I format <valueRef> from "<source-format>" to "<target-format>" as <name>
Where
<valueRef>is the name of the binding containing the source date/time value- Can be the name of any binding that contains or resolves to a date/time value, including a web element in which case the text in the element will be dynamically retrieved and used.
<source-format>is the source date time format pattern to convert from<target-format>is the target date time format pattern to convert to<name>is the name to bind the formatted date/time value to
Example
Given ISO date is "2026-03-14"
When @DateTime I format ISO date from "yyyy-MM-dd" to "dd/MM/yyyy" as dmy date
Then dmy date should be "14/03/2026"
Since v4.18.1, Gwen also supports ordinal suffixes (1st, 2nd, 3rd, 4th, etc..)
Given ISO date is "2026-03-02"
When @DateTime I format ISO date from "yyyy-MM-dd" to "d(st|nd|rd|th) MMMM yyyy" as display date
Then display date should be "2nd March 2026"
And (converting the other way)
Given display date is "23rd Mar 2026"
When @DateTime I format display date from "d(st|nd|rd|th) MMM yyyy" to "yyyy-MM-dd" as ISO date
Then ISO date should be "2026-03-23"