i have a problem setting a datetime attribute to the current date , if i force it to current timestamp i get a " Call to a member function format() on string" ERROR
**here are my getter and setter with some modifications**
public function getDateajout()
{
date_default_timezone_set('Africa/Tunis');
$dateajout=date_default_timezone_get();
return $this->dateajout;
}
public function setDateajout($dateajout)
{
$this->dateajout =$dateajout;
}
You could return a \DateTime object as example:
/**
*
* @return \DateTime
*/
public function getDateajout()
{
return new \DateTime('now', (new \DateTimeZone('Africa/Tunis'));
}
Hope this help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With