Reformat date using PHP

edavo
edavo used Ask the Experts™
on
Right now, I place a date on my page using the echo $rows['date']; variable from a query. It works fine, but it is printed out as:

2011-09-10

How do I use php to show the output as only:

09/10
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
Someone had suggest this:

echo date('m/d', $rows['date']);

But it prints out all 12/31 for all records regardless of the actual date being pulled from the db...
President
Commented:
How about:

echo date('m/d', strtotime($rows['date']));

Cheers,
K.
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Try this.  http://us.php.net/manual/en/function.explode.php
$nudate = explode("-", $rows['date']);
echo $nudate[1]."/".$nudate[2];

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial