📜  如何在 laravel 中计算年龄 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:30.405000             🧑  作者: Mango

代码示例1
use Carbon\Carbon; // Include Class in COntroller

$request->date_of_birth = "2000-10-25";
$age = Carbon::parse($request->date_of_birth)->diff(Carbon::now())->y;

dd($age. " Years"); // To check result