Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > บทความจากสมาชิก > Calculate Age By PHP คำนวนอายุด้วย PHP By DEVPOP



 
Clound SSD Virtual Server

Calculate Age By PHP คำนวนอายุด้วย PHP By DEVPOP

Calculate Age By PHP Calculate Age By PHP คำนวนอายุด้วย PHP By DEVPOP

Code (PHP)
<?php
$dateofbirth = "1987-05-16";
/*
	Calculate age for details
*/

function getAges($dateofbirth) {

$today = date("Y-m-d");
/*
function
	list : Assign variables as if they were an array.
	explode : Break a string into an array.
*/
list($byears, $bmonth, $bday) = explode("-", $dateofbirth);
list($tyears, $tmonth, $tday) = explode("-", $today);

if($byears < 1970) {
	$yearad = 1970 - $byears;
	$byears = 1970;
}else {
	$yearad = 0;
}

$mbirth = mktime(0,0,0, $bmonth, $bday, $byears);
$mtoday = mktime(0,0,0, $tmonth, $tday, $tyears);

$mage = ($mtoday - $mbirth);
$wyears = (date("Y", $mage)-1970+$yearad);
$wmonths = (date("m", $mage)-1);
$wdays = (date("d", $mage)-1);

$ystr = ($wyears > 1 ? " YEARS" : " YEAR");
$mstr = ($wmonths > 1 ? " MONTHS" : " MONTH");
$dstr = ($wdays > 1 ? " DAYS" : " DAY");

if($wyears > 0 && $wmonths > 0 && $wdays > 0) {
	$agestr = $wyears.$ystr." ".$wmonths.$mstr." ".$wdays.$dstr;
}else if($wyears == 0 && $wmonths == 0 && $wdays > 0) {
	$agestr = $wdays.$dstr;
}else if($wyears > 0 && $wmonths > 0 && $wdays == 0) {
	$agestr = $wyears.$ystr." ".$wmonths.$mstr;
}else if($wyears == 0 && $wmonths > 0 && $wdays > 0) {
	$agestr = $wmonths.$mstr." ".$wdays.$dstr;
}else if($wyears > 0 && $wmonths == 0 && $wdays > 0) {
	$agestr = $wyears.$ystr." ".$wdays.$dstr;
}else if($wyears == 0 && $wmonths > 0 && $wdays == 0) {
	$agestr = $wmonths.$mstr;
}else {
	$agestr ="";
}

return $agestr;
}

echo getAges($dateofbirth);


Credit by : http://www.ubu.ac.th/ocn_blog/blog/buncha-37
Modify By : itechs

Display :
age by php
Contact :
facebook : www.facebook.com/itechs
LINE : devpop
Phone : 089-4915453
Dowload : https://drive.google.com/folderview?id=0B9WBIvRSivz9WmxacUJra3N1M00&usp=sharing







   
Share
Bookmark.   

  By : Crazyt[e]Am
  Article : บทความเป็นการเขียนโดยสมาชิก หากมีปัญหาเรื่องลิขสิทธิ์ กรุณาแจ้งให้ทาง webmaster ทราบด้วยครับ
  Score Rating :
  Create Date : 2014-07-28
  Download : No files
Sponsored Links
ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่