[PHP] 생일로 나이 계산

PHP/functions 2008/09/26 18:10
나이계산때문에....메모

<?php
$birth_time   = strtotime('1995-01-02');
$now          = date('Ymd');
$birthday     = date('Ymd' , $birth_time);
$age           = floor(($now - $birthday) / 10000);
?>

위는 만 나이 계산.

한국 나이로 계산은
<?php
$birth_time   = strtotime('1995-01-02');
$now          = date('Y');
$birthday     = date('Y' , $birth_time);
$age           = $now - $birthday + 1 ;
?>

만 나이 계산때문에 귀찮아서...메모해둠.
 

'PHP > functions' 카테고리의 다른 글

smarty variable modifier - wordwrap  (0) 2009/02/23
[PHP] 생일로 나이 계산  (2) 2008/09/26
PHP 디렉토리 함수 (dir)  (0) 2008/05/07
tags :
Trackback 0 : Comments 2