Posted By

cigraphics on 05/23/10


Tagged

time day date


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

karp13


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


 / Published in: PHP
 

  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  

You need to login to post a comment.