Re: [PHP-DB] newbie needs to format time field
thanks so much, I've gotten a lot from that page of the mySQL documentation... but I'm still needing little more help. I am currently using the following PHP to generate my page (with results displayed in standard mySQL date and time formats): $db = mysql_connect(localhost, username, password); $result = mysql_query(SELECT * FROM table order by date,$db); $myrow = mysql_fetch_array($result)); printf(%s,$myrow[date]); printf(%s,$myrow[time]); printf(%s,$myrow[description]); Should I change my query to something like this: $result = mysql_query(SELECT *,DATE_FORMAT(date,'%m/%d/%y')) FROM tableorder by date,$db); I tried using that query, but then I didn't know how to get the formatted date out of the array field in my PRINTF lines (what goes in the [ ]?) Should I use two different queries, so that I have $result1 and $result2, then $myrow1 and $myrow2, like this: $result1 = mysql_query(SELECT * FROM table order by date,$db); $result2 = mysql_query(SELECT DATE_FORMAT(date,'%m/%d/%y')) FROM table order by date,$db); $myrow1 = mysql_fetch_array($result1)); $myrow2 = mysql_fetch_array($result2)); Thanks for everyone's time if not for newsgroups, I don't how I'd learn anything! Eric Schwinder eric.AT.bergencomputing.DOT.com Torgil Zechel [EMAIL PROTECTED] wrote: Checkout: http://www.mysql.com/doc/D/a/Date_and_time_functions.html the function DATE_FORMAT(date,format) does what you want... I have a mySQL database that I am using PHP to interface with. I have fields in the database that are DATE and TIME types. Can I format these values so that the user sees September 15, 2001 or 2:00 PM instead of 2001-09-15 and 14:00:00 when I show the values on the web page? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] newbie needs to format time field
on 9/5/01 9:22 PM, Eric J Schwinder at [EMAIL PROTECTED] wrote: thanks so much, I've gotten a lot from that page of the mySQL documentation... Here's another one for you: http://www.mysql.com/doc/S/E/SELECT.html quote A SELECT expression may be given an alias using AS. /quote So instead of: SELECT DATE_FORMAT(date,'%m/%d/%y') FROM ... You could do this: SELECT DATE_FORMAT(date,'%m/%d/%y') AS mydate FROM ... I tried using that query, but then I didn't know how to get the formatted date out of the array field in my PRINTF lines (what goes in the [ ]?) Using the above code, the value you're looking for is mydate, i.e., echo $myrow['mydate']; HTH. Sincerely, Paul Burney ++ Paul Burney Webmaster Open Source Developer UCLA - GSEIS - ETU (310) 825-8365 [EMAIL PROTECTED] http://www.gseis.ucla.edu/ ++ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] newbie needs to format time field
This may be a dumb question but here goes: I have a mySQL database that I am using PHP to interface with. I have fields in the database that are DATE and TIME types. Can I format these values so that the user sees September 15, 2001 or 2:00 PM instead of 2001-09-15 and 14:00:00 when I show the values on the web page? If so, can anyone suggest a reference which will help me do this? I didn't find anything in the mySQL or PHP manuals, but maybe I was looking in the wrong places! Thanks in advance from a relatively new PHP user! Eric J Schwinder eric.AT.bergencomputing.DOT.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
SV: [PHP-DB] newbie needs to format time field
Checkout: http://www.mysql.com/doc/D/a/Date_and_time_functions.html the function DATE_FORMAT(date,format) does what you want... -Ursprungligt meddelande- Från: Eric J Schwinder [mailto:[EMAIL PROTECTED]] Skickat: den 3 september 2001 21:39 Till: [EMAIL PROTECTED] Ämne: [PHP-DB] newbie needs to format time field This may be a dumb question but here goes: I have a mySQL database that I am using PHP to interface with. I have fields in the database that are DATE and TIME types. Can I format these values so that the user sees September 15, 2001 or 2:00 PM instead of 2001-09-15 and 14:00:00 when I show the values on the web page? If so, can anyone suggest a reference which will help me do this? I didn't find anything in the mySQL or PHP manuals, but maybe I was looking in the wrong places! Thanks in advance from a relatively new PHP user! Eric J Schwinder eric.AT.bergencomputing.DOT.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]