Jump to content

[SOLVED] format date


AdRock

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.