Reputation: 2496
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.
Upvotes: 1
Views: 414
Reputation: 3949
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');
Upvotes: 1