views:

52

answers:

3

Iam getting the date and time from Database as follows

Date : 20100101(YYYY/MM/DD) Time : 120912 (HH:MM:SS)

I have to format the Date as follows 20100101 --> (2010-10-11) (look to have ) "-" in between year and month and Day

I have to format the time as follows 120912 --> 12:02:12 suppose I may have the time as 62367 from the database

06:23:67

+3  A: 

This is what you need:

http://www.electrictoolbox.com/formatting-dates-with-php/

Leniel Macaferi
+1  A: 

I recommend you convert the data using: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

Felipe Cardoso Martins
I think it's easier to do this in PHP than in SQL
captaintokyo
A: 

we can use DATE_FORMAT(fieldname,format ) function in mysql For Example we can use DATE_FORMAT( a.date, '%d-%m-%Y' )

Martin s