Written by Sean Behan on Sat Nov 11th 2017

Calculate age in PHP

$your_birthday = '1982-08-29';
$difference = date_diff(date_create(), date_create($your_birthday));
$age      = $difference->format('%Y');
// 35

Short and sweet


Tagged with..
#php #snippets #dates #times #code

Just finishing up brewing up some fresh ground comments...