Pulling DATE from database using MySQL and PHP

Hi Guys,

I have a little problem with pulling a DATE from a database. Below is my code for the page I am trying to create.

I have in the database a date – 2011-07-27 and I am trying to set the dates into an array so that I can organise dates into YEAR and MONTH.

Now, I don’t know if the database is the problem. The field is set to DATE.

// Add each entry to the $data array, sorted by Year and Month
while($row = $result->fetch_assoc())
{
$year = date(‘Y’, $row['articleDate']);
$month = date(‘m’, $row['articleDate']);

$data[$year][$month][] = $row;
}
$result->free();

The above code returns 1970 for year and 01 for month.

Help Please :)

Thank you

View full post on Tycoon Talk

, , , , ,

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes


RSS Site FeedRSS Site Feed

© 1992-2011 DC2NET™, Inc. All Rights Reserved