derek.sullivan
May 27 2009, 07:20 PM
when you the table row type is DATE, and you use CURDATE() to insert the date, the format is YYYY-MM-DD, is there a way in PHP to rotate the format to MM-DD-YYYY but still inserting it the way it's sapose to in the DB just changing the format on the page it's being displayed from?
derek.sullivan
May 27 2009, 07:33 PM
I figured it out.... For all of you who are wondering as well here is my code:
before: YYYY-MM-DD
CODE
<?php
$date = list($year, $month, $day)=split('[/.-]', $row['date']); // [/.-] searches for the symbol(s) / . or -
$date = "$month-$day-$year";
echo $date;
?>
after: MM-DD-YYYY
enjoy!
rc69
May 27 2009, 09:26 PM
So you know,
list() doesn't return anything, so the following line should not have "$date = "
CODE
$date = list($year, $month, $day)=split('[/.-]', $row['date']); // [/.-] searches for the symbol(s) / . or -
derek.sullivan
May 28 2009, 02:36 PM
But it works still doesn't it???
rc69
May 28 2009, 05:34 PM
Only because PHP is interpreted. If it were a compiled language, something would probably yell at you.
Either way, it is not a practice you should get into.
derek.sullivan
May 28 2009, 06:40 PM
witchcraft isn't a practice i should get into either
rc69
May 28 2009, 10:05 PM
Ok, congradulations on solving the problem then.
derek.sullivan
May 29 2009, 11:28 AM
battles are hard to win with hard-headed men

thanks BTW lol
sanitarium
May 30 2009, 08:19 AM
you can use onlt timestamp
i think that's more easy
derek.sullivan
May 30 2009, 09:05 AM
Correct, but I want to get acquainted with all mysql fields, rows, querys, etc etc...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.