Answer the question
In order to leave comments, you need to log in
How to count dates (calculate age) in PHP (dates are stored in Unix Time)?
You need to calculate the age based on the specified date of birth. Date of birth information is contained in Unix Time.
I'm not strong in PHP, I just started editing my existing code to get what I need.
Let me give you an example just to understand:
$tpl->set( '{birthday}', langdate( "D M Y", $row['birthday'] ) );
$tpl->set( '{age}', текущая дата - $row['birthday'] ) );
Answer the question
In order to leave comments, you need to log in
/** @var \DateTime $dateBirth */
$diff = (new \DateTime())->diff($dateBirth);
$formatted = sprintf("%d лет", $diff->y);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question