note 94901 added to function.date

From: Date: Wed, 02 Dec 2009 05:46:00 +0000
Subject: note 94901 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-163472@lists.php.net to get a copy of this message
<?php //this function can be used to calculate the number of years and months experiance of a employee in a company. //example 4.6 means 4 years 6 months. $dateofjoin="2007-11-01"; $date_diff=calculate_date_diff($$dateofjoin); echo $date_diff; function calculate_date_diff($doj1) { $doj1=strtotime($doj1); $doj=date("m/d/Y",$doj1); $now=date("m/d/Y"); //this can be changed as the date you want. I am calculating till date $year=date("Y"); $x=explode("/",$doj); $y1=explode("/",$now); $yy=$x[2]; $mm=$x[0]; $dd=$x[1]; $yy1=$y1[2]; $mm1=$y1[0]; $dd1=$y1[1]; $mn=0; $mn1=0; $ye=0; if($mm1>$mm) { $mn=$mm1-$mm; if($dd1<$dd) { $mn=$mn-1; } $ye=$yy1-$yy; } else if($mm1<$mm) { $mn=12-$mm; if($mm!=1) { $mn1=$mm1-1; } $mn+=$mn1; if($dd1>$dd) { $mn+=1; } $yy=$yy+1; $ye=$yy1-$yy; } else { $ye=$yy1-$yy; $ye=$ye-1; $mn=12-1; if($dd1>$dd) { $ye+=1; $mn=0; } } //$to=$ye." years and ".$mn." months"; //this can be echoed to view return $ye.".".$mn; } ?> ---- Server IP: 202.65.157.132 Probable Submitter: 202.65.136.107 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/94901 Del: integrated -- https://master.php.net/note/delete/94901/integrated Del: useless -- https://master.php.net/note/delete/94901/useless Del: bad code -- https://master.php.net/note/delete/94901/bad+code Del: spam -- https://master.php.net/note/delete/94901/spam Del: non-english -- https://master.php.net/note/delete/94901/non-english Del: in docs -- https://master.php.net/note/delete/94901/in+docs Del: other reasons-- https://master.php.net/note/delete/94901 Reject -- https://master.php.net/note/reject/94901 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#163472) next »