OK here's a problem that I have torn my hair out over several times , and I thought I would share the solution cos im assuming other people have had it as well...
When you use PHP to grab a Date field from a MySQL database you get it in the format
yyyy-mm-dd
which you CANT do proper date formatting in PHP with , what you want is
Question
Rathamon
OK here's a problem that I have torn my hair out over several times , and I thought I would share the solution cos im assuming other people have had it as well...
When you use PHP to grab a Date field from a MySQL database you get it in the format
yyyy-mm-dd
which you CANT do proper date formatting in PHP with , what you want is
mm-dd-yyyy
here's the code I used
$datequery = "select mydate from mytable";
$dateresult = mysql_query($datequery);
$datearray = mysql_fetch_array($dateresult);
$thedate = $datearray['startdate'];
list($y,$m,$d) = explode('-', $thedate);
$properdate = date("jS F Y", mktime(0, 0, 0, $m, $d, $y));
Obviously you want to change the SQL (and maybe the variables)
to suit your needs...
Link to comment
Share on other sites
2 answers to this question
Recommended Posts