<?phpif(isset($_POST['dd'])){$day1 = $_POST['dd'];$mon1 = $_POST['mm'];$yea1 = $_POST['yy'];$day2 = date("d");$mon2 = date("m");$yea2 = date("Y");$keepitbaby = array();//echo "Days: ". ($day1-$day2)."<br>";//echo "Months: ". ($mon1-$mon2)."<br>";//echo "Years: ". ($yea1-$yea2)."<br>";//echo "<br>day2................".$day2."<br>";// day1,mon1,yea1 is the inputs from usersif( $day1 > $day2 ){$day11 = ($day2+30);$day12 = ($day11 - $day1);echo "You have lived in this earth <u> ".($day12+1)." </u> Days ";array_push($keepitbaby, (($day12+1)."-"));$mon22 = ($mon1+1); // firiye dilam zei mas nisi taif( $mon2 < $mon22){$mon33 = ($mon2 + 12 );$mon44 = ($mon33 - $mon22);echo "<u>".$mon44." </u> Months and ";array_push($keepitbaby, ($mon44."-") );$yea66 = ($yea1+1);$yea99 = ($yea2 - $yea66);echo "<u>".$yea99." </u> Years! And counting...";array_push($keepitbaby, $yea99."-");}else {$mon55 = ($mon2 - $mon22);echo "<u>".$mon55." </u> Months and ";array_push($keepitbaby, $mon55."-");$yea9 = ($yea2 - $yea1);echo "<u>".$yea9." </u> Years! And countiung....";array_push($keepitbaby, $yea9."-");}}else {$day33 = ($day2 - $day1);echo "You have lived in this earth <u>".$day33." </u> Days ";array_push($keepitbaby, $day33."-");if( $mon1 > $mon2){$mon333 = ($mon2 + 12 );$mon444 = ($mon333 - $mon1);echo "<u>".$mon444." </u> Months and ";array_push($keepitbaby, $mon444."-");$yea66 = ($yea1+1);$yea99 = ($yea2 - $yea66);echo "<u>".$yea99." </u> Years! And counting...";array_push($keepitbaby, $yea99."-" );}else {$mon555 = ($mon2 - $mon1);echo "<u>".$mon555."</u> Months and ";array_push($keepitbaby, $mon555."-");$yea9 = ($yea2 - $yea1);echo "<u>".$yea9."</u> Years! And counting...";array_push($keepitbaby, $yea9."-" );}}//$keeps = array();// print_r($keepitbaby);// $keeps = implode($keepitbaby);// echo "<br>booooooooooooooooooooooooooooooooooooo";//echo $keeps;// print_r($keeps);$tt = 0;$kemo = 0;for($mk=0; $mk < sizeof($keepitbaby);$mk++) {if(($keepitbaby[$mk]) == "-"){break;}else{$tt++;// echo "<br>boom ".($keepitbaby[$mk]*3)."<br>";if($tt==1){$km = $kemo+($keepitbaby[$mk]*86400);}elseif($tt==2){$km = $kemo+($keepitbaby[$mk]*30*86400);}elseif($tt==3){$km = $kemo+($keepitbaby[$mk]*365*86400);}else echo "Error";}}echo "<br><br><h6 style='color: #8FBC8F;'>You are on the earth for around ".$km." Seconds, ".($km/60)." Minutes, ".($km/3600)." hours and ".($km/86400)." Days!<h6>";// echo "<br><br> You are on the earth for ".(($km/86400)/365)." Years!";}?>
Using these codes you can easily make a age calculator in PHP. The codes are brought to you by CarnivalBD IT Team
No comments:
Post a Comment