eval.in

Paste #120620

PHP — PHP 5.5.1, pasted 1 year ago

1
2
3
4
5
6
7
8
9
<?php


$age = 72;
$str = '24 July 1976';

$date = date_create($str);
date_sub($date, date_interval_create_from_date_string("$age years"));
echo date_format($date, 'Y-m-d');

Program Output

1904-07-24

OK (0.004 sec real, 0.006 sec wall, 14 MB, 43 syscalls)

Fork