So if I use:
<?php echo date_format($date, "j M Y") ?>
I get a date in the following format: 5 Jan 1950.
However, what I want is something along the lines of: 5th Jan 1950
How would I go about adding the extra th?
Look at the formats here http://www.php.net/manual/en/function.date.php, but
<?php echo date_format($date, "jS M Y") ?><br>
For international dates, I guess you would do something like:
$ordinal = new NumberFormatter($locale, NumberFormatter::ORDINAL);
$ordinal = $ordinal->format(date_format($date, "j"));
$pattern = "d'{$ordinal}' MMM yyyy";
$dateFormatter = new IntlDateFormatter($locale, IntlDateFormatter::FULL, IntlDateFormatter::FULL, $timezone, IntlDateFormatter::GREGORIAN);
$dateFormatter->setPattern($pattern);
$dateFormatter->format($date->getTimestamp());
The above is untested but it seems like it would work.
echo date_format($date, "jS M Y");
Just check the documentation.
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