Carbon Laravel, get current time according to timezone

 Syntax -

- Carbon::now('Asia/Kolkata')->format('h:i:s A');

or

Carbon::now('+05:30')->format('h:i:s A');


Example:-

  public function carbontest()
    {
       
// current time of india according to timezone place
       return Carbon::now('Asia/Kolkata')->format('h:i:s A');

//current time of india according to timezone
        //return Carbon::now('+05:30')->format('h:i:s A');


        // format('h:i:s A') ==> hours:minute:seconds AM/PM
        // format('h:i:s a') ==> hours:minute:Seconds am/pm


    }

Output:-

12:09:04 AM


Format parameter meaning

Comments