![]() |
Problems with my date format
Hi,
Today is 11th December 2012 I have my date stored in my MySql dbase as a datetime in this format: 2012-12-11 00:00:00 I want to output it as m/d/y format. So I would like: 12/11/12 I have tried this: PHP Code:
Anyone know how I correct this problem ? Thanks . |
The problem is, the date function expects a timestamp as the second parameter and not a mysql date.
Try this: PHP Code:
|
Quote:
|
Hi,
Thanks for replies. I tried: PHP Code:
I looked at the MYSQL link and think I need this: PHP Code:
Thanks |
I would suspect you have a cached page there. If pub_date is 2009-10-04 22:23:00, that is valid.
The DATE_FORMAT is used in SQL, not in PHP. Simply modify the query and add the DATE_FORMAT(pub_date, '%m/%d/%Y') AS formattedDate, then pull the formattedDate from the resultset. |
So my query is :
PHP Code:
DATE_FORMAT(pub_date, '%m/%d/%Y') AS formattedDate then I'll have to list all the records I guess ?? ( there are about 18 of them ) It seems to me it would be nicer to just reformat the result for that record. Something like : PHP Code:
Thanks. . |
This is fine:
PHP Code:
PHP Code:
Code:
Date: 10/04/09SELECT *, DATE_FORMAT(pub_date, '%m/%d/%Y') AS formattedDate FROM. . . is fine. |
Thanks :thumbsup:
I have it working now :) |
| All times are GMT +1. The time now is 05:26 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.