Skip to content

Instantly share code, notes, and snippets.

@appkr
Last active May 13, 2017 07:18
Show Gist options
  • Save appkr/240d90112f4f1b18ae146d3165a38e68 to your computer and use it in GitHub Desktop.
Save appkr/240d90112f4f1b18ae146d3165a38e68 to your computer and use it in GitHub Desktop.
Timemachine For Testers
<?php // app/Providers/AppServiceProvider.php
namespace App\Providers;
use Carbon\Carbon;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
Carbon::setTestNow(Carbon::now()->addDays(5));
}
}
<?php // app/Http/Controllers/HealthController.php
namespace App\Http\Controllers;
use Carbon\Carbon;
class HealthController extends Controller
{
public function index()
{
return response()->json([
'Date' => Carbon::now()->format('D, d M Y H:i:s').' GMT',
], 200, [
'Date' => Carbon::now()->format('D, d M Y H:i:s').' GMT'
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment