In one the my project we need to calculate user age from data of the birth. It is very easy to calculation age fro data of birth. For more details check out the following snippet:
1 2 3 4 5 6 7 |
# object oriented $from = new DateTime('1992-01-04'); $to = new DateTime('today'); echo $from->diff($to)->y; echo "</br>"; echo date_diff(date_create('1992-01-04'), date_create('today'))->y; |
Reference link stackoverflow and download code from here Thanks for reading and let me know need any changes.
Recent Comments