I have my users entering the date in this format :- mm/dd/yyyy (11/21/2012)
My PHP script converts the date into the following format :- dd-Month-yyyy (21-November-2012)
I do this using :-
$new_date = date('d-F-Y', strtotime($user_date));
How can I have the date in this format :- 21st November 2012
?
Thanks
You can use S
letter as following:
$new_date = date('jS F Y', strtotime($user_date));
Check manual.
It will output as you expect
$my_date = '2016-01-01'; echo date('F jS, Y', strtotime($my_date)); # January 1st, 2016
while dS will also prepends 0
echo date('F dS, Y', strtotime($my_date)); # January 01st, 2016
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With