How Can I Convert A Mysql Timestamp Into A Format I Want Using Php?
I have a colum in a MySQL database that uses datatype TIMESTAMP to save the date and time that a new row is inserted. This displays like 2008-09-21 09:31:25 when retrieved and echoed using PHP.
How can I use PHP to display the data like 21-Sep-08?
Related posts:
- How To Use Php Code Stored In Mysql Database? I know how pull data from the database but I...
- How To Code A Simple Php Dynamic Dropdown Form Feild From Mysql? I been struggling with this all morning. I am tiring...
- display MySQL database rows alphabetically Learn more about display MySQL database rows alphabetically by visiting...
- Display rows from only a certain category of a MySQL database Learn more about Display rows from only a certain category...
- Show MySQL tables Learn more about Show MySQL tables by visiting our website....
Related posts brought to you by Yet Another Related Posts Plugin.


June 29th, 2009 at 11:29 pm
print date(”d-M-y”, strtotime(’2008-09-21 09:31:25′))
Will do the trick nicely!
strtotime() will take just about any date format and give you a timestamp.
June 29th, 2009 at 11:29 pm
Try following piece of code
< ?php
$strTimeStamp = "2008-09-21 09:31:25";
$arrTimeStamp = explode(" ", $strTimeStamp);
$strDate = $arrTimeStamp[0];
$arrDate = explode("-", $strDate);
echo date("d-M-y", mktime(0,0,0,$arrDate[1], $arrDate[2], $arrDate[0]));
?>
June 29th, 2009 at 11:29 pm
use the Date() function , which takes two params : one being the timestamp and the other formatting string to specify how the date is presented.