fork download
  1. <?php
  2.  
  3. $person1 = getBirthDate('03/11/1972');
  4. echo $person1[0];
  5.  
  6. //$person2 = getBirthDate('02/08/1991');
  7. //echo $person2[0] . " " . $person2[1];
  8. function getBirthDate($input){
  9. $x=explode("/",$input);
  10. $i=count($x);
  11.  
  12.  
  13. $days=8;
  14. $months=2;
  15.  
  16. if(($days==$x[$i-2]) && ($months==$x[$i-3])){
  17. $isbirthday=true;
  18. }
  19. if($isbirthday==true){
  20. echo "Today is the birthday. \n";
  21. $years=(2012-($x[$i-1]));
  22. }
  23. else{
  24. echo "Today is not the birthday. \n";
  25. $years=(2012-($x[$i-1]))-1;
  26. }
  27.  
  28. $years=(2012-($x[$i-1]));
  29. $totaldays = ($years * 365);
  30.  
  31. if($months>=1){
  32. $totaldays+=31;
  33. }
  34. if($months>=2){
  35. $totaldays+=29;
  36. }
  37. if($months>=3){
  38. $totaldays+=31;
  39. }
  40. if($months>=4){
  41. $totaldays+=30;
  42. }
  43. if($months>=5){
  44. $totaldays+=31;
  45. }
  46. if($months>=6){
  47. $totaldays+=30;
  48. }
  49. if($months>=7){
  50. $totaldays+=31;
  51. }
  52. if($months>=8){
  53. $totaldays+=31;
  54. }
  55. if($months>=9){
  56. $totaldays+=30;
  57. }
  58. if($months>=10){
  59. $totaldays+=31;
  60. }
  61. if($months>=11){
  62. $totaldays+=30;
  63. }
  64. if($months>=12){
  65. $totaldays+=31;
  66. }
  67. $totaldays+=$days;
  68. $totalyears=intval($totaldays/365);
  69. $isbirthday = false;
  70.  
  71. echo $totalyears. "\n";
  72.  
  73. $returnarray=array($totalyears, $isbirthday);
  74. }
  75. ?>
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
Today is not the birthday. 
40