I'm having trouble with getting the weeknumber out of a date. Users have to fill in a date which gets posted in my database.
In the next fase I need to retrieve the date from my database and get the number of the week out of this date. I'm using this code to get the week out of the date, but it's not working properly.
<?=$deliverydate = new DateTime($order->delivery_date);
$week = $deliverydate->format("W");?>
<?php $week?>
Errormessage: Object of class DateTime could not be converted to string.
Thanks in advance!
Regards Bert
<?php
$ddate = "2021-11-12";
$date = new DateTime($ddate);
$week = $date->format("W");
echo "Weeknummer: $week";
?>