I am storing appointments by adding 15 minutes to current date as default appointment duration and trying to add Minutes to a date obtained by following code:
$curr_date=new DateTime(date("Y-m-d H:i:s"));--Obtained the current date and time.
$curr_date->add(new DateInterval('P15M'));--Adding 15 minutes
But when I save the Model it throws error saying:
Object of class DateTime could not be converted to string
Any help would be greatly appreciated.
You'll need to format the date so the SQL query if generated the right way. Use format when you put value into your model.
$my_model->myattribute = $curr_date->format('Y-m-d H:i:s');