-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalumnos.php
More file actions
40 lines (31 loc) · 903 Bytes
/
alumnos.php
File metadata and controls
40 lines (31 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
class Alumnos {
private $nombre;
private $apellido1;
private $apellido2;
private $direccion = array();
private const $DNI;
private const $NACIMIENTO = array();
private $edad = array();
private function __construct($name, $apellido1, $apellido2, $direccion, $dni, $nacimiento){
$this->nombre = $name;
$this->apellido1 = $apellido1;
$this->apellido2 = $apellido2;
$this->direccion = $direccion;
$this->DNI = $dni;
$this->NACIMIENTO = $nacimiento;
$this->obtener_edad();
}
public function obtener_edad(){
$timestamp_actual = time();
$dias_edad = date_diff($this->NACIMIENTO,$timestamp_actual);
$anos_con_decimales = $dias_edad / 365.25;
$anos = int($anos_con_decimales);
$dias_restantes = $anos_con_decimales - $anos;
$dias = $dias_restantes * 365.25 / 100;
$this->edad[0]= $anos;
$this->edad[1]= $dias;
//return $this->edad;
}
}
?>