Soldato
Not sure how to explain this, i'm no expert with PHP apart from the basics and I want to have the easiest solution possible.
I have a mysql table of which there is a number of rows and I want to give each row a date. I have a field called "date" which is setup as a datetime field and when using phpmyadmin to insert a row it works fine, I end up with a date of, for example 2013-01-04 11:23:55. When using the code below I can select the date field and it prints the date fine, in the same format as phpmyadmin shows.
Now I want to format this date in php so that I end up with, lets say, "4-Jan-2013" and I used to use this small bit of code when I was doing things 'my way'
and that worked fine however I can't do things my way, i'm stuck with having to use array's as part of the Zen framework as i'm trying to customise part of a forum called Xenforo. As such I have to use the following array and I can't for the life of me work out how to format the date. Whether it's even possible or whether it's a case of storing the date differently in a int field or such like.
This is the code I currently have
It selects everything I need and prints everything to the screen, how and where do I enter the ability to alter the format of the date field?
I have a mysql table of which there is a number of rows and I want to give each row a date. I have a field called "date" which is setup as a datetime field and when using phpmyadmin to insert a row it works fine, I end up with a date of, for example 2013-01-04 11:23:55. When using the code below I can select the date field and it prints the date fine, in the same format as phpmyadmin shows.
Now I want to format this date in php so that I end up with, lets say, "4-Jan-2013" and I used to use this small bit of code when I was doing things 'my way'
PHP:
$date = date('d-m-Y', $date);
and that worked fine however I can't do things my way, i'm stuck with having to use array's as part of the Zen framework as i'm trying to customise part of a forum called Xenforo. As such I have to use the following array and I can't for the life of me work out how to format the date. Whether it's even possible or whether it's a case of storing the date differently in a int field or such like.
This is the code I currently have
PHP:
public function getModule()
{
$mystuff = $this->_getDb()->fetchAll('SELECT * FROM `matches` ORDER BY `date` DESC LIMIT 10');
foreach ($mystuff as &$stuff)
{
$stuff = array(
'opponent' => $stuff['opponent'],
'date' => $stuff['date'],
'event' => $stuff['event'],
'score' => $stuff['score'],
'result' => $stuff['result']
);
}
return $mystuff;
}
It selects everything I need and prints everything to the screen, how and where do I enter the ability to alter the format of the date field?
Last edited: