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