PHP: Working with Dates

If you need to calculate days, you can perform that using the EVAL action.

See How to evaluate a PHP commands to manipulate variables and clipboard (Experimental feature) for details on EVAL action.

PHP syntax

Reference: https://php-legacy-docs.zend.com/manual/php5/en/function.date

date(format, date);

Code samples:

date('d.m.Y',strtotime("- 10 Days"))
date('d.m.Y',strtotime("yesterday"))
date('d.m.Y',strtotime("tomorrow"))
date('d.m.Y',strtotime("+ 3 weeks"))
date('d.m.Y',strtotime("- 2 Months"))
date('d.m.Y',strtotime("now"))
date('d.m.Y',strtotime("next Saturday"))
date('d.m.Y',strtotime("last Year"))

Example

1) Set a value to variable “days_before” in Editor->Data :
“days_before” = 10

2) Use EVAL in a test step with this constant:

EVAL "".date('d.m.Y', strtotime("-".${"days_before"}." Days") )

Running this EVAL action on today’s date 23.04.2022 results in a clipboard value 13.04.2022

Free Webinar

Uncover the secrets of automated testing in the free webinar.

Revolutionize Your Testing Process with AI-Powered Automation.

Test our
AI-Promt Feature for FREE