bravo14 0 Posted July 2, 2008 Share Posted July 2, 2008 Hi all The date format in the mysql database is yyyy-mm-dd and I want to display the date dd-mmm-yyyy I have tried using the following code after having a look at other sites echo ('<tr><td>'.$row[Date].(j-M-Y)'</td><td><b>Yardley</b></td>'); and I am getting the following error Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/fhlinux147/y/yardleyheroes.co.uk/user/htdocs/fixtures.php on line 59 Can anyone give me any pointers Link to post Share on other sites
DarkWater 0 Posted July 2, 2008 Share Posted July 2, 2008 1) You need to use the DATE_FORMAT() MySQL function on your query. What type is the column in the DB? 2) Use ' ' around your array keys please... Link to post Share on other sites
br0ken 0 Posted July 2, 2008 Share Posted July 2, 2008 Is this what you want? <?php echo "<tr><td>".date("j-M-Y", $row[Date])."</td><td><b>Yardley</b></td>"; ?> Link to post Share on other sites
DarkWater 0 Posted July 2, 2008 Share Posted July 2, 2008 date() expects a timestamp, br0ken. Link to post Share on other sites
br0ken 0 Posted July 2, 2008 Share Posted July 2, 2008 date() expects a timestamp, br0ken. I assumed he'd stored a timestamp in the database and that's what he was retrieving... Link to post Share on other sites
DarkWater 0 Posted July 2, 2008 Share Posted July 2, 2008 "The date format in the mysql database is yyyy-mm-dd..." =X I think he used a DATE or DATETIME. It would be helpful if he posted. Link to post Share on other sites
Barand 1,617 Posted July 2, 2008 Share Posted July 2, 2008 ... and the required format is "dd-mmm-yyyy", not "d-mmm-yyyy". So echo "<tr><td>".date("d-M-Y", strtotime($row['Date']))."</td><td><b>Yardley</b></td>"; @br0ken, When was "yyyy-mm-dd" a unix timestamp? No need to assume, read the first post, first sentence Link to post Share on other sites
bravo14 0 Posted July 3, 2008 Author Share Posted July 3, 2008 Sorry guys should have said the field is a date field not datetime does that make any difference to what I am trying to achieve? Link to post Share on other sites
Barand 1,617 Posted July 3, 2008 Share Posted July 3, 2008 Date field is fine. Link to post Share on other sites
Recommended Posts
Archived
This topic is now archived and is closed to further replies.