Click to See Complete Forum and Search --> : Timestamp Dates in MySQL


mitcon
09-06-2005, 02:06 PM
I would like to display the date portion of a MySQL timestamp column. The format of this date-time field must not be recognized as a Unix date-time variable. I say this because the Date() function of PHP does not format the output correctly when doing something like:

date($row["create_date"], "d-M-Y")

where $row["create_date"] contains the results of the mysql_fetch_array() function.


Does anyone have any idea how to format the date portion of a timestamp field to be displayed as:

06-Sep-2005

Thanks in advance...

NogDog
09-06-2005, 02:52 PM
$query = "SELECT *, UNIX_TIMESTAMP(`timestamp_field`) AS `unixtime` FROM `table_name`";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
echo "<p>Formatted time = " . date("d-M-Y", $row['unixtime'] . "</p>\n";
}

mitcon
09-06-2005, 03:42 PM
Nogdog:

Thanks for the reply. I did exactly what I hate others doing...asking a question BEFORE searching for other similar threads on the forum.

I found your other post from some time ago...It worked perfect...Nice and clean!

Thanks for your input on this forum.

Mitch

By the way, do you have a technique for making "not" blink only 9 times or is Schrodinger's cat special? <g>

NogDog
09-06-2005, 06:02 PM
Schrodinger's cat is both alive and dead until someone observes it and collapses the quantum wave function. :)