Related content

Sometimes when we seed data in Laravel, we may need a date between generators. You know that the faker also provides dates between helpers. In this tutorial, you will learn laravel faker random date between. Using the dateTimeThisMonth() helper, can get a date between current month. 

Let's see the example code of laravel faker generate unique dates in range:


use App\Models\Product;
use Faker\Factory as Faker;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class ProductSeeder extends Seeder
     * Run the database seeds.
     * @return void
    public function run()

        $faker = Faker::create();
        for ($i=1; $i < 101 ; $i++) { 
            $product = new Product;
            $product->date = $faker->dateTimeThisMonth();


Read also: Laravel 9 Use Faker Outside Factory Example



I have tried to discuss the clear concept of laravel faker random date between. Now we know laravel faker date range. Hope laravel faker start and end date tutorial will help you.