Forum Moderators: coopster

Message Too Old, No Replies

Displaying dates

         

dave1236

1:58 am on Oct 10, 2006 (gmt 0)

10+ Year Member



Quick question -

I have my dates stored in my MySQL DB with an expiration associated with it. These are stored in Y-m-d format (Yahoo default (I beleive MySQL as well))

How do I convert these dates to display as a a "regular date"?

I have tried to name my variable in the way I want, but I simply destroy the integrity of the file by doing so.

Thanks!

eelixduppy

2:50 am on Oct 10, 2006 (gmt 0)



It depends on what you consider to be a "regular" date. Here is an example using MySQL:

$query = "SELECT DATE_FORMAT(date_col,'%m/%d/%Y') AS date_name";
// selects in the format:

Look up more about the DATE_FORMAT function here: Date and Time Functions [dev.mysql.com]

Good luck :)

eelixduppy

10:49 am on Oct 10, 2006 (gmt 0)



I just realized how asleep I was for my last post:

$query = "SELECT DATE_FORMAT(date_col,'%m/%d/%Y') AS date_name FROM table_name";

..although I think you got the point before :)

Sorry about that!

mrnoisy

11:59 am on Oct 10, 2006 (gmt 0)

10+ Year Member



$getdate="SELECT date from table_name";
$getdate=mysql_query($getdate) or die(mysql_error());
$getdate=mysql_fetch_array($getdate);

echo date('F j, Y', strtotime($getdate));

PHP date reference [php.net]