Can anyone tell what is wrong with the code.
$timezone = "Asia/Karachi";
$date = new DateTime($when_to_send, new DateTimeZone($timezone));
$date = $date->setTimezone(new DateTimeZone('GMT'));
$when_to_send = $date->format('Y-m-d H:i:s');
error is: Call to a member function format() on a non-object
$date = $date->setTimezone(new DateTimeZone('GMT'));
Makes the $date variable null, you should just call it:
$date->setTimezone(new DateTimeZone('GMT'));
If you're not running at least PHP 5.3.0 (as written in the manual, which you surely read before asking, right?), setTimezone
will return NULL instead of the modified DateTime. Are you running at least PHP 5.3.0?
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