trouble formatting date stored in MYSQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kristie380
Forum Commoner
Posts: 36
Joined: Sun Oct 09, 2005 10:51 pm

trouble formatting date stored in MYSQL

Post by kristie380 »

HELP! I am trying to post the date that is stored in MYSQL onto my php page but it just keeps returning Dec. 31, 1969. What am I doing wrong? Here is my code:

Code: Select all

$date = explode("-", $date_modified);
$final_date = date("M d Y", mktime(0,0,0,$date[0],$date[1],$date[2]));
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

dates in MySQL are stored in YYYY-MM-DD format.

Code: Select all

$date = explode("-", $date_modified);
$final_date = date("M d Y", mktime(0,0,0,$date[1],$date[2],$date[0]));
kristie380
Forum Commoner
Posts: 36
Joined: Sun Oct 09, 2005 10:51 pm

Post by kristie380 »

Thanks! I always miss something small like that :)
Post Reply