Avatar of edavo
edavoFlag for United States of America

asked on 

Reformat date using PHP

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
MySQL Server

Avatar of undefined
Last Comment
Dave Baldwin
Avatar of edavo
edavo
Flag of United States of America image

ASKER

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...
ASKER CERTIFIED SOLUTION
Avatar of Kerem ERSOY
Kerem ERSOY

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

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

Open in new window

MySQL Server
MySQL Server

MySQL is an open source, relational database management system that runs as a server providing multi-user access to a number of databases. Acquired by Oracle in 2009, it is frequently used in combination with PHP installations, powering most of the WordPress installations.

49K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo