When I pull the date out of the db, it comes back like this:
2009-10-14T19:00:00
I want to format it in two different ways...
The first: F d, Y The second h:m (12 hour format)
Everything I try returns December 1969... Help?! I feel so confused...
When I pull the date out of the db, it comes back like this:
2009-10-14T19:00:00
I want to format it in two different ways...
The first: F d, Y The second h:m (12 hour format)
Everything I try returns December 1969... Help?! I feel so confused...
This is basic date functionality:
$dt = new DateTime('2009-10-14T19:00:00');
echo $dt->format('F d, Y');
echo $dt->format('h:m');
Try this PHP code.
<?php
echo date('F d, Y', strtotime('2009-10-14T19:00:00'));
echo date('h:m', strtotime('2009-10-14T19:00:00'));
?>
You should do this in you SQL query:
SELECT DATE_FORMAT(`date`,'%M %e, %Y') FROM table ORDER BY date DESC
Where 'date' is the name of your date column and 'table' is your table. This will return the date in the format of October 14, 2009.
If you wish to retrieve the other format, use:
SELECT DATE_FORMAT(`date`,'%H:%i:%s') FROM table ORDER BY date DESC
You will then just need to access the values from the table columns using PHP which I assume you can already do based upon your question.