Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. <?php
  2.  
  3. // Assuming the date you're looking for is January 2:
  4. $when = 'January 2';
  5.  
  6. // Verbose method:
  7. if(($date = strtotime($when)) < time()) {
  8. $date = strtotime('+1 year', $date);
  9. }
  10.  
  11. // If you need this as a one-liner...
  12. $date = (strtotime($when) < time()) ? strtotime('+1 year', strtotime($when)) : strtotime($when);
  13. echo date('m/d/Y', $date);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement