Forum Moderators: open

Message Too Old, No Replies

Date format in MySQL + PHP

Date format of dd-Mon-yy

         

vinitjain75

12:26 am on Dec 1, 2007 (gmt 0)

10+ Year Member



Hi,

I am not able to get the date displayed in the following format in the php page using MySql

dd-Mon-yy
30-Nov-07 or 01-Dec-2007

Please help.

Regards
VJ

rocknbil

5:07 am on Dec 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard!

select date_format(now(),'%d-%a-%y');
select date_format(curdate(),'%d-%a-%y');
30-Fri-07
select date_format(now(),'%d-%a-%Y');
select date_format(curdate(),'%d-%a-%Y');
30-Fri-2007

Substitute your column name for now() or curdate();

Date_format() [dev.mysql.com] and other date and time functions

vinitjain75

9:37 am on Dec 1, 2007 (gmt 0)

10+ Year Member



Thank you!

I was looking for this

SELECT date_format( 'ColumnName', '%d-%b-%y' )

My problem was SELECT date_format( 'ColumnName', '%d-%b-%y' ) as StartDate

Without using the "as" clause, I was not able to move it into the array.

Regards
VJ

rocknbil

5:49 pm on Dec 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't need the quotes around ColumnName, in fact, you may not even need the as . . . but if it works, it works!

vinitjain75

7:33 pm on Dec 1, 2007 (gmt 0)

10+ Year Member



Thanks

But I am using the functions of phpbb and am assigning the value of date into the template array using the field name and not the raw index.

Hence, I need the as clause.

Yes I am not using the quotes.

Regards
VJ