Carbon Add Hours In Laravel

<?phpnamespace App\Http\Controllers;use Illuminate\Http\Request;
use Carbon\Carbon;
class DateController extends Controller
{
public function index()
{
$currentDateTime = Carbon::now();
$newDateTime = Carbon::now()->addHour();
print_r($currentDateTime);
print_r($newDateTime);
}
}
Carbon\Carbon Object
(
[date] => 2020-12-07 09:45:30.376461
[timezone_type] => 2 [timezone] => GMT
)
Carbon\Carbon Object
(
[date] => 2021-12-07 10:45:30.376461
[timezone_type] => 2 [timezone] => GMT
)
<?phpnamespace App\Http\Controllers;use Illuminate\Http\Request;
use Carbon\Carbon;
class DateController extends Controller
{
public function index()
{
$currentDateTime = Carbon::now();
$newDateTime = Carbon::now()->addHours(3);
print_r($currentDateTime);
print_r($newDateTime);
}
}
Carbon\Carbon Object
(
[date] => 2020-12-07 09:46:32.406561
[timezone_type] => 2 [timezone] => GMT
)
Carbon\Carbon Object
(
[date] => 2023-12-07 12:46:50.454561
[timezone_type] => 2 [timezone] => GMT
)

--

--

--

I am Laravel and PHP Developer. I have also Good Knowledge of JavaScript, jQuery, Bootstrap and REST API.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

P2P connection with WebRTC

Automation and deployment of Go applications to staging and Production environments using, Docker…

Devops

Git intro

AMAZON EKS 💥

Akka Actors — Part 1: Why Akka in the first place?

Visual Programming Is Unbelievable… Here’s Why We Don’t Believe In It

Vitess: Easy database deployment, clustering, and scaling!

Roblox Drive City Codes November

Roblox Drive City Codes November

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Websolutionstuff

Websolutionstuff

I am Laravel and PHP Developer. I have also Good Knowledge of JavaScript, jQuery, Bootstrap and REST API.

More from Medium

OAuth2 Authentation Line Login Laravel — Part 3

Laravel resizes all images in a folder

How to send mail using Gmail in Laravel 9?

How to send mail using Gmail in Laravel 9?

Laravel orderBy, groupBy and limit Example