AdRock Posted March 26, 2009 Share Posted March 26, 2009 This is probably an easy one but i've never had to use it before until now and it's doing my head in I have a date field in my database and need to order by date so formatting the date in the SQL is not an option I want to format the date so it looks like 14th March 2009 or something similar. I tried using strtotime and strftime which works but I am struggling with the day. How can I get the day number and is there st, nd, th etc to follow the day? <?php echo strftime("%e %B %Y", strtotime("2009-03-16 11:33:54")); ?> Link to comment https://forums.phpfreaks.com/topic/151301-solved-format-date/ Share on other sites More sharing options...
kenrbnsn Posted March 26, 2009 Share Posted March 26, 2009 Use date <?php echo date('jS F Y', strtotime("2009-03-16 11:33:54")); ?> Ken Link to comment https://forums.phpfreaks.com/topic/151301-solved-format-date/#findComment-794766 Share on other sites More sharing options...
AdRock Posted March 26, 2009 Author Share Posted March 26, 2009 Thanks...i'll rememebr that in future Link to comment https://forums.phpfreaks.com/topic/151301-solved-format-date/#findComment-794768 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.