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?
mysql, date
Started by derek.sullivan, May 27 2009 07:20 PM
9 replies to this topic
#1
Posted 27 May 2009 - 07:20 PM
#2
Posted 27 May 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
after: MM-DD-YYYY
enjoy!
before: YYYY-MM-DD
<?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!
#4
Posted 28 May 2009 - 02:36 PM
But it works still doesn't it???
Edited by derek.sullivan, 28 May 2009 - 02:37 PM.
#5
Posted 28 May 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.
Either way, it is not a practice you should get into.
#6
Posted 28 May 2009 - 06:40 PM
witchcraft isn't a practice i should get into either
#7
Posted 28 May 2009 - 10:05 PM
Ok, congradulations on solving the problem then.
#8
Posted 29 May 2009 - 11:28 AM
battles are hard to win with hard-headed men
thanks BTW lol
#9
Posted 30 May 2009 - 08:19 AM
you can use onlt timestamp
i think that's more easy
i think that's more easy
#10
Posted 30 May 2009 - 09:05 AM
Correct, but I want to get acquainted with all mysql fields, rows, querys, etc etc...
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
