I have date of each post stored in date
field in db. The format is DD/MM/YYYY (eg : 24/12/2013). Field is VARCHAR(50)
I want to print Day and month in a page (A Blog listing page). ie like "24 DEC" (Doesnt need year)
What's the best possible way to achieve it
Note : I'm using PHP
Please start storing dates in Y-m-d format in DATE
fields. Your life, and ours, would be much easier.
Until then, use this php solution:
$dt = DateTime::createFromFormat('!d/m/Y', '24/12/2013');
echo strtoupper($dt->format('j M')); # 24 DEC
demo
or mysql solution:
SELECT STR_TO_DATE('24/12/2013','%d/%m/%Y')
Try this: You need to reverse the date i.e. Y/m/d format.
$date = strtotime('2013/12/24');
echo date('j M ', $date);
Output:
24 Dec
See in PHP Date Manual
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