Ecovoyageurs
Member
Hi,
Just a basic PHP question but I can't find a solution anywhere...
I have 2 calc elements that get time value under format hh:mm:ss
Now, in a PHP plugin onafterprocess, I'd like to add these 2 times and save the result in db (to use it later in a time field, so hh:mm:ss format would be great).
I tried with strftotime and datetime :
Like :
$heure_depart = "{fk_demandes___heure_depart_calc}";
$duree = "{fk_demandes___duree_calc}";
$heure_ret = strtotime($heure_depart)+strtotime($duree);
$heure_retour = strftime("%H:%M:%S",$heure_ret);
Or :
$heure_depart = "{fk_demandes___heure_depart_calc}";
$duree = "{fk_demandes___duree_calc}";
$start_hour = new DateTime($heure_depart);
$length = new DateTime($duree);
$return_hour = $start_hour->add($length);
$heure_retour = $return_hour->format('%H:%I:%S');
... yet couldn't get it working.
Thanks for any help !
Just a basic PHP question but I can't find a solution anywhere...
I have 2 calc elements that get time value under format hh:mm:ss
Now, in a PHP plugin onafterprocess, I'd like to add these 2 times and save the result in db (to use it later in a time field, so hh:mm:ss format would be great).
I tried with strftotime and datetime :
Like :
$heure_depart = "{fk_demandes___heure_depart_calc}";
$duree = "{fk_demandes___duree_calc}";
$heure_ret = strtotime($heure_depart)+strtotime($duree);
$heure_retour = strftime("%H:%M:%S",$heure_ret);
Or :
$heure_depart = "{fk_demandes___heure_depart_calc}";
$duree = "{fk_demandes___duree_calc}";
$start_hour = new DateTime($heure_depart);
$length = new DateTime($duree);
$return_hour = $start_hour->add($length);
$heure_retour = $return_hour->format('%H:%I:%S');
... yet couldn't get it working.
Thanks for any help !