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:-
Format parameter meaning
Comments
Post a Comment
If you any doubt of any topic then you can comment me.