Forum Moderators: coopster

Message Too Old, No Replies

How to display date in other format on the html page

from www-mm-dd in July 02.2008

         

rowtc2

9:28 pm on Jul 1, 2008 (gmt 0)

10+ Year Member



I have stored in database a date in format yyy-mm-dd

My php code display 2008-07-01 date (like in sql)
$date=$row["date"];
echo" $date

But i need two display July 02,2008 . Any suggestions ?

cameraman

9:42 pm on Jul 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



date [us2.php.net]('F d, Y',strtotime [us.php.net]($row['date']))

dreamcatcher

7:14 am on Jul 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or let the database do the work:

mysql_query("SELECT *,DATE_FORMAT [dev.mysql.com](date,'%M %d, %Y') AS new_date...

echo $row['new_date'];

dc

g1smd

8:39 pm on Jul 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The YYYY-MM-DD format is defined in ISO 8601, ANSI X3.30 and RFC 3339, and as such it is the most widely understood date format of all.

Why not just display it "as is" - or with same Y M D order but with the month as a three-letter abbreviation? In lists, this really is much easier on the eye.

dreamcatcher

7:36 am on Jul 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why not just display it "as is" - or with same Y M D order but with the month as a three-letter abbreviation? In lists, this really is much easier on the eye.

As is is no good if you live in the UK. Or just changing the month. The date format is different here. Displaying it as YYYY-MM-DD isn`t very easy on the eye to us Brits as its the US date format. We don`t use that format here.

cameraman

11:41 am on Jul 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually US date format is MM-DD-YYYY. I've only seen that format when dealing with databases. I suppose it could be an emerging trend that I'm not aware of, but I've yet to run across a 'regular user' who likes it (they say, "can't you switch that around?") - I think most people agree with DC that it's not very easy on the eye, although I like it since it's ms...ls and facilitates sorts ;)

g1smd

8:44 pm on Jul 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



*** YYYY-MM-DD isn`t very easy on the eye to us Brits as its the US date format. ***

Nope. Old US is MM-DD-YYYY, and old UK is DD-MM-YYYY.

Today is 07-03-2008 in one country and 03-07-2008 in the other.

In ISO 8601, it is 2008-07-03 today, as YYYY-MM-DD format, and that works because NO-ONE on the planet uses yyyy-dd-mm at all.

The UK signed into the ISO standards in 1972. The US agreed to the same formats in 1968. Most of the world had signed by the late 1980's.

It's agreed as an Internet Standard in RFC 3339 and W3C have recommended its usage for more than a decade in [w3.org...] and [w3.org...] and [w3.org...] and other places.

It's now the only date format in the official HTML 5 [w3.org...] specification.