Alter berechnen

PHOTO EMBED

Mon Sep 02 2024 06:49:43 GMT+0000 (Coordinated Universal Time)

Saved by @2late #php

<?php
  //date in mm/dd/yyyy format; or it can be in other formats as well
  $birthDate = "09/03/1960";
  //explode the date to get month, day and year
  $birthDate = explode("/", $birthDate);
  //get age from date or birthdate
  $age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md")
    ? ((date("Y") - $birthDate[2]) - 1)
    : (date("Y") - $birthDate[2]));
  echo "Age is:" . $age;
?>
content_copyCOPY

Berechnet aus Tag, Monat und Jahr das aktuelle Alter.