Closed prashant-pokhriyal closed 6 years ago
UTCDateTime::__construct()
has accepted a DateTimeInterface
since version 1.2.0. The php --ri mongodb
and php -i
output you shared is certainly coming from a CLI environment, where you do have version 1.4.4 of the extension installed. What is the output of phpversion('mongodb')
when run from the same PHP environment that throws the InvalidArgumentException.
"expects parameter 1 to be integer, object given" reads like a generic zend_parse_parameters()
error. In version 1.1.10, we only accepted an integer argument (or string for 32-bit systems). In 1.4.4, you can see the possible InvalidArgumentExceptions we now throw:
Expected instance of DateTimeInterface, %s given
Expected integer or string, %s given
This leads me to believe that your PHP environment is running a older version of the extension.
Hello, I got the same error when when I try to update a record and my fix was:
$yesterdaySameTime = Carbon::createFromTimestamp(Carbon::now()->subHours(24)->timestamp)->toDateTimeString();
Model::where('status', 'Active')
->where('updated_at', '>', new UTCDateTime((new \DateTime($yesterdaySameTime))->getTimestamp()))
->update([
'status' => 'Expired'
]);
Closing this out as there was no further feedback. Please feel free to reopen in case more information comes to light.
Description
I'm not able to use DateTime in UTCDateTime constructor. It throws InvalidArgumentException
Environment
OS: Ubuntu 16.04 PHP: 7.0.30-0ubuntu0.16.04.1
I installed php using
apt-get install php7.0
.Output of
php --ri mongodb
:Output of
php -i
:Output of
php -m
: