| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Senior Member
Join Date: Oct 2004
Location: Chester
Posts: 364
|
convert date into a viewable format
Hi all, I am trying to display a last updated date field on my web page. Currently I retrieve the date via this piece of code: <p>Last Updated: <?php echo $row_rsHome['date']; ?></p> How do I format this date to show the date as: 8th November, 2004. Many thanks in advance |
|
|
|
|
|
#5 (permalink) |
|
Senior Member
Join Date: Oct 2004
Location: Chester
Posts: 364
|
I have done that but it is returning 19th January, 2038. BTW Your code returned a blank page: So I changed the single quotes to double quotes and it worked fine. Sorry my mistake, it was actually the bracket that needed to be swapped with the semi-colon. Last edited by NickToye : 08-11-2004 at 19:46. |
|
|
|
#9 (permalink) | |
|
I Ain't Losing Any Sleep™
Join Date: Apr 2003
Posts: 5,206
|
Quote:
this works Code:
http://www.lifeofsmallbeer.co.uk/tests/date.php That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
|
|
|
|
|
#10 (permalink) | |
|
Magazines™
Join Date: Mar 2003
Location: Glasgow..
Posts: 11,886
|
Quote:
fucks sake smallone if your going to help at least put the effort in. |
|
|
|
|
#11 (permalink) | |
|
Senior Member
Join Date: Oct 2004
Location: Chester
Posts: 364
|
Quote:
I think I'm being a little stupid here, but where can I put this mySQL code? in my php page? This is my current code: Code:
|
|
|
|
|
#13 (permalink) |
|
Senior Member
Join Date: Oct 2004
Location: Chester
Posts: 364
|
Ok this is my query in my php file: $query_rsHome = "SELECT * FROM home"; So basically how do I adapt this to what you have suggested, because when I try: $query_rsHome = "SELECT date_format(date, %D %M % Y), * FROM home"; it gives me an error. |
|
|
|
#14 (permalink) | |
|
Senior Member
Join Date: Feb 2004
Location: Exeter
Posts: 773
|
Quote:
you need it like this: $query_rsHome = "SELECT date_format(date, %D %M % Y) as date, * FROM home"; But instead of the * you need to list the other fields |
|
|
|
|
#19 (permalink) |
|
hmmm...
Join Date: Jan 2004
Location: Yorkuk
Posts: 2,127
|
I generally store my dates in mysql as native dates, then just use the following function to convert. Code:
usage: Code:
For what you need, you won't need to go the other way, as you can just use NOW() on your insert query. |
|
|
|
#20 (permalink) | |
|
Senior Member
Join Date: Oct 2004
Location: Chester
Posts: 364
|
Quote:
Code:
This is my query: Code:
|
|
|
![]() |