How To Convert Time Format AM PM With Laravel Carbon

Hello artisan,

In this example, I will show you how to convert time format into am pm in laravel using carbon. In this example, I will give you an example of laravel carbon convert am pm time format. From this example, we will see a concept of laravel carbon am pm. We will look at an example of converting time to am pm in laravel carbon. I will share with you how to convert time into am and pm in laravel.

I will share with you the source code of converting time format into AM PM with carbon in Laravel. You know that Laravel carbon provides a format() method to convert time to am and pm. we will use "g:i A" format as an argument to convert am and pm time. so let's see the example code below:



namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Carbon\Carbon;
class DemoController extends Controller
     * Write code on Method
     * @return response()
    public function index(Request $request)
        $now = Carbon::now();
        $time = $now->format('g:i A');


Read also: How to Get Age from Date of Birth in Laravel


Hope it can help you.


#laravel #carbon