use Carbon\Carbon; // Set current time to 1st January 2021 12 PM Carbon::setTestNow(Carbon::parse('2021-01-01 12:00:00')); // Perform testing operations
// Set current time as 2 hours ahead of current time Carbon::setTestNow(Carbon::now()->addHours(2)); // Perform testing operationsIn this example, we are setting the current time as 2 hours ahead of the current time. This can be useful when testing time-sensitive operations that require a specific time to be set in the future. Package library: Carbon is part of the package Carbon\Carbon.