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.25);
  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. $isbirthday = false;
  56. if($totaldays%365.25==0){
  57. $isbirthday=true;
  58. }
  59.  
  60.  
  61. $returnarray=array('age' => $totaldays, 'birthday'=>$isbirthday);
  62. }
  63. ?>
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout