Forums

How to adjust time using a php function?

cyberspyder 25 Jul, 2020
I am trying to use the built in date function (created time) for my "from" date and I need to add one year to be a "to" date.

Here is the code in my PHP block:
$date = $this->date;
$validUntil = date('Y-m-d H:i:s', strtotime($date. ' + 1 year'));
return $validUntil;

Then in my Save function here is my code: {var:php43.validUntil}

I am assuming my PHP knowledge is lacking and my code has an error because the value I get when I try to save it is null.
Max_admin 25 Jul, 2020
you should call this with {var:php43} only, the value of this is the return value, your current code would work if you return an array ["validUntil" => 123]
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
healyhatman 26 Jul, 2020
{date:Y-m-d $(data:form_field_name) + 1 year}
This topic is locked and no more replies can be posted.