 |
|
Code (PHP)
<?php
$birthday = "1986-06-01"; //รูปแบบการเก็บค่าข้อมูลวันเกิด
$today = "2016-10-03"; //จุดต้องเปลี่ยน
list($byear, $bmonth, $bday)= explode("-",$birthday); //จุดต้องเปลี่ยน
list($tyear, $tmonth, $tday)= explode("-",$today); //จุดต้องเปลี่ยน
$mbirthday = mktime(0, 0, 0, $bmonth, $bday, $byear);
$mnow = mktime(0, 0, 0, $tmonth, $tday, $tyear );
$mage = ($mnow - $mbirthday);
$u_y=date("Y", $mage)-1970;
$u_m=date("m",$mage)-1;
$u_d=date("d",$mage)-1;
echo $u_y."/ ". $u_m."/ ". $u_d ;
?>
ผลออกมา ตรงวันที่เหมือนเอาวันปัจจุบันมาคำนวณอ่ะครับ

Tag : PHP, MySQL, JAVA
|
|
 |
 |
 |
 |
Date :
2016-10-05 17:17:09 |
By :
suparop |
View :
977 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |