Search
 
SCRIPT & CODE EXAMPLE
 

PHP

carbon add days from specific date

#1. let's define a date with format Y-m-d
$date = "2022-01-03";

#2. what we want is to add a number of days from initial date and get the new date.
# 2.1 convert initial date with carbon
$c_init_date = CarbonCarbon::createFromFormat('Y-m-d', $e_join_date);

# 2.2 add number of days from $c_init_date. let's say 7 days
$new_date = $carbon_now->addDays(7)->format("Y-m-d");

#3. the result must be "2022-01-10"
die($new_date);
Comment

Carbon Add Days To Date In Laravel

<?php
  
namespace AppHttpControllers;
  
use IlluminateHttpRequest;
use CarbonCarbon;
  
class DateController extends Controller
{
    public function index()
    {
        $currentDateTime = Carbon::now();
        $newDateTime = Carbon::now()->addDay();
             
        print_r($currentDateTime);
        print_r($newDateTime);
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: créer projet laravel 
Php :: php parse json 
Php :: union of two arrays in php 
Php :: how to check if input is number only in php 
Php :: php get all the mondays of the year 
Php :: laravel install production 
Php :: difference between two timestamps php 
Php :: rtl file manager laravel 
Php :: display summernonte data with string limit laravel 
Php :: get first 200 characters string php 
Php :: use if in laravel blade 
Php :: console.log in php 
Php :: showing database table in php 
Php :: check php version linux terminal 
Php :: sort multi array php 
Php :: php return json 
Php :: laravel convert number to si 
Php :: get params from url php 
Php :: laravel get query in normal sql without bindings 
Php :: larvel check two password 
Php :: debian install apache php 
Php :: func_get_args with keys 
Php :: php check if get var is set 
Php :: delete all rows from table laravel 
Php :: fix excel file wrong language php 
Php :: wp-config.php repair 
Php :: Get Parameters From a URL String in PHP 
Php :: form submitting twice 
Php :: php repeat string 
Php :: how count the rout in route.php laravel 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =