PDA

View Full Version : PHP date format...PLS HELP



outback
August 12th, 2009, 06:55 PM
Hi all,

I've been trying to change the date format of my website for a long time nowand nothing seems to work. I've tried to change it on MySQL but I'm not getting it right.

here is the line of code I'm using to call the date from the database:


<?php echo $row_rs_nw['date'];?>


what I need is to change the format from yyyy/mm/dd to mm/dd/yyyy....

PLS HELP!!! thanks for the attention!!

NeoDreamer
August 13th, 2009, 12:57 AM
I usually store my dates in MySQL as Unix timestamp, so I'd do:



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


But you're storing your date as some other weird format so, try:



echo substr($row_rs_nw['date'], 5, 2) . '/' .
substr($row_rs_nw['date'], 8, 2) . '/' .
substr($row_rs_nw['date'], 0, 4);

outback
August 13th, 2009, 08:15 AM
Thank u!!!!!