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. $totaldays = ($years * 365);
  29.  
  30. if($months>=1){
  31. $totaldays+=31;
  32. }
  33. if($months>=2){
  34. $totaldays+=29;
  35. }
  36. if($months>=3){
  37. $totaldays+=31;
  38. }
  39. if($months>=4){
  40. $totaldays+=30;
  41. }
  42. if($months>=5){
  43. $totaldays+=31;
  44. }
  45. if($months>=6){
  46. $totaldays+=30;
  47. }
  48. if($months>=7){
  49. $totaldays+=31;
  50. }
  51. if($months>=8){
  52. $totaldays+=31;
  53. }
  54. if($months>=9){
  55. $totaldays+=30;
  56. }
  57. if($months>=10){
  58. $totaldays+=31;
  59. }
  60. if($months>=11){
  61. $totaldays+=30;
  62. }
  63. if($months>=12){
  64. $totaldays+=31;
  65. }
  66. $totaldays+=$days;
  67. $totalyears=intval($totaldays/365);
  68. $isbirthday = false;
  69.  
  70. echo $totalyears. "\n";
  71.  
  72. $returnarray=array($totalyears, $isbirthday);
  73. return $returnarray;
  74. }
  75. ?>
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
Today is not the birthday. 
39
39