How to set date value into mongodb with insert method?

456 Views Asked by At

Adding data into mongodb with insert method :

   $published_at = $faker->dateTimeBetween($startDate = '-200 days', $endDate = 'now', config('app.timezone'));

   $todayEnd = Carbon::now(config('app.timezone'));

   $data[] = [
      ...
      'published_at' => !empty($published_at->date) ? $published_at->date: null,
      'created_at' => $todayStart,

But checking in I see that published_at has null value and created_at has “{}” value. Which way is valid ?

Laravel 9
jenssegers/mongodb 3

Thanks in advance!

0

There are 0 best solutions below