Add st, nd, rd, th to days :D


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function fday($time) {
  2. $day = date('d', $time);
  3. if ( substr($day, -1) == 1 ):
  4. $end = 'st';
  5. elseif ( substr($day, -1) == 2 ):
  6. $end = 'nd';
  7. elseif ( substr($day, -1) == 3 ):
  8. $end = 'rd';
  9. else:
  10. $end = 'th';
  11. endif;
  12.  
  13. return date('F, d', $time).$end.date(' Y', $time);;
  14. }
  15.  
  16. Usage:
  17. $time = time();
  18. echo fday($time);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.