Guest User

Untitled

a guest
Jan 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. function year($day, $month) {
  2. // ...
  3. return $year;
  4. }
  5.  
  6. year($day, $month) {
  7.  
  8. $today_day = date('d');
  9. $today_month = date('m');
  10.  
  11. $year = date('y');
  12.  
  13. if($month > $today_month) {
  14. return $year;
  15. } else if ($month < $today_month) {
  16. return $year + 1;
  17. } else {
  18. if($day >= $today_day) {
  19. return $year;
  20. } else {
  21. return $year + 1;
  22. }
  23. }
  24.  
  25. }
  26.  
  27. function year($day, $month) {
  28. $date = new DateTime("{$month}/{$day}"); // defaults to current year
  29. $today = new DateTime();
  30. if ($date <= $today) {
  31. $today->modify('+1 year');
  32. }
  33.  
  34. return $today->format('Y');
  35. }
  36.  
  37. echo year(6, 6); // 2017
  38. echo year(12, 12); // 2016
  39.  
  40. function year($month, $day)
  41. {
  42. $date= date('Y').'-'.$month.'-'.$day;
  43. if (strtotime($date) > time()) {
  44. return date('y');
  45. }
  46. return (date('y')+1);
  47. }
  48.  
  49. echo year(12,25); // 16
  50.  
  51. echo year(2,25); // 17
Add Comment
Please, Sign In to add comment