A
A
ART42021-09-27 22:35:48
PHP
ART4, 2021-09-27 22:35:48

How to find out how many years and months?

We need to find out how many years and months the child is based on the array

array(2) { 
   [0]=> string(2) "08" 
   [1]=> string(2) "16" 
 }

[0] => month
[1] =>

year of birth
The day can be random, any.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
v3shin, 2021-09-28
@ART4

$a = ['08', '16'];
$diff = (new \DateTime())->diff(new \DateTime("20$a[1]-$a[0]-01"))->format('%yy %mm');

https://www.php.net/manual/en/datetime.diff.php
https://www.php.net/manual/en/dateinterval.format.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question