PHP code example of max13 / faker-dateinterval
1. Go to this page and download the library: Download max13/faker-dateinterval library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
max13 / faker-dateinterval example snippets
$faker = new Faker\Generator;
// Add this provider to Faker
$faker->addProvider(new FakerDateInterval\FakerProvider($faker));
// Generate a date, time or date and time interval
$date = $faker->dateInterval(/* $complex = */false, /* $asIso8601 = */ false);
$time = $faker->timeInterval(/* $complex = */false, /* $asIso8601 = */ false);
$datetime = $faker->dateTimeInterval(/* $complex = */false, /* $asIso8601 = */ false);
// return DateInterval objects
// You can generate a complex interval with more than 1 part generated
$date = $faker->dateInterval(/* $complex = */true, /* $asIso8601 = */ false);
// You can also retrieve the interval as an ISO8601 duration string
$date = $faker->dateInterval(/* $complex = */true, /* $asIso8601 = */ true);
// returns a string like: P1M3D for 1 month and 3 days