This topic is locked
[SOLVED]

Event Using DATE_ADD

1/12/2025 3:38:32 AM
PHPRunner General questions
H
Hopper author

I have the following code on my Add Page > Before Record Added

$values['policy_expire_date']= date_add('.$values['policy_start_date'].',interval '.$values['policy_period'].' day);

I have tried revising multiple times and continue to get the following error message.

Parse error: syntax error, unexpected 'policy_start_date' (T_STRING), expecting ')' in C:\Projects\Attendance Management System (AMS)\output\include\ams_team_members_events.php on line 55

Thanks for any guidance.

GNH

C
Chris Whitehead 1/12/2025

for the command date_add, using that syntax is for the mysql command.

Here's some examples I found for the php version.

$date=date_create("2024-03-15");
date_add($date,date_interval_create_from_date_string("40 days"));
echo date_format($date,"Y-m-d");
$date = date_create("25-09-1989");
$interval = date_interval_create_from_date_string('1025 days');
$res = date_add($date, $interval);
$format = date_format( $res, "d-m-Y H:i:s");
print($format);
H
Hopper author 1/12/2025

Thank you Chris. The did the trick!