|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
Hi,
I am using a mySQL database to retreive date information and i am not sure how to format this information in php to a differnt format. Ive looked @ the date function in php but that only seems to work with the currnet local date and the date_format function in sql only seems to work in mySQL and not thru php. Any help would be appreciated CMatrix |
|
#2
|
|||
|
|||
|
Look in the online mysql documentation, section 7.4.11. It will explain how mysql can format a date field into almost any desired format.
exp. select DATE_FORMAT('1997-10-04 22:23:00', '% %M %Y'); -> 'Saturday October 1997' later |
|
#3
|
|||
|
|||
|
You didn't answer his question.
I'm having the same problem btw. How do you get a MySQL date formated in PHP? I need to get it from yyyy-mm-dd to: mm/dd/yy. I can do it from the MySQL command line interactively, but there seems to be no PHP API function for this. PHP also only seems to work with local dates through the date function. I am a PHP/MySQL novice, and I'm finding it hard to find an example to study. |
|
#4
|
|||
|
|||
|
If you can manipulate mysql dates on the command line, then you know how to manipulate them in php. Just send the appropriate select statement via mysql_query().
$result=mysql_query("select some,fields,date_format('format string',datefield) as fdate from table"); If you really want to manipulate the date format in php then you'll need to retrieve the date as a unixtimestamp. $result=mysql_query("select unix_timestamp(datefield) as utstmp from table"); |
|
#5
|
|||
|
|||
|
The problem i was having was that I just needed to do a mysql_fetch_row[0] to get the result from mysql select date_format command since it returns the result as an array with 1 row
cmatrix |
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > formating mySQL dates in php |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|