Wednesday, 15 May 2013

mysql - Trying to apply PHP date format -


I am trying to apply a specific date format from MySQL. I column field type is 'date' and an example is 2015 -03-16 is formatted in MySQL, and those dates are without date NULL .

When I apply the following code, the fields are displayed correctly along with the date - 03/16/2015.

However, all the tap fields of MySQL are displayed in the webpage with 31/12/69 any ideas what I can do?

  if (! $ VoSl_Name, Builder, Created, Listing_Price, Date_Listed, LOA, Price_Original, Price_Previous, Amt_Reduced, Amt_Pct from Boats)) "echo" query Can not parse "; } Otherwise (mysql_num_rows ($ rs) == 0) {resonant "no record was found"; } Else {echo " Vessel_Name "; Echo "  Builder ;"; Echo "
created "; Echo "& lt; th> listing price & lt; / th & gt;"; Echo "& lt; th & gt; listed date & lt; / th & gt;"; Echo "> LOA "; Echo "& lt; th> original value ;"; Echo " previous price "; Echo "& lt; th & gt; mt reduced & lt; / th & gt;"; Echo " AMT PTT ;"; Echo "& lt; / tr & gt; \ n & lt; / thead & gt; \ n"; While ($ line = mysql_fetch_array ($ RS)) {Echo " & lt; TD & gt; $ ROW [Builder] gt; $ line [build] & lt; / td> gt; td & gt; $ line [listing_Price] & lt; / td & gt; ; & Lt; td & gt; Date ("d / m / y", strtotime ($ line ['Date_Listed'])) ". & Lt; / td> gt; td & gt; $ line [loa] gt; ; & Lt; td & gt; $ line [Price_Reduced] & lt; / td> gt; & lt; td & gt; $ line [Price_Previous] & lt; / td> & lt; td & gt; $ line [Amt_Reduced] $ line [Amt_Pct] \ n "; } Echo "

OK, you have to identify the memories of dates and instead, do something else Therefore

  while ($ line = mysql_fetch_array ($ rs)) {$ fixed_date = $ row ['Date_Listed'] == 'NULL'? 'N / a': Date ("m / d / y", stronteme ($ line ['Date_Listed'])); Echo "& lt; tr & gt; & lt; td & gt; $ line [Vessel_Name] & lt; / td & gt; & lt; td & gt; $ line [builder] & lt; / td & gt; Lt; td & gt; $ line [construction] & lt; / td> gt; & lt; td & gt; $ line [listgrius] & lt; / td & gt; & lt; td & gt; $ Fixed_date ". & Lt; / td> gt; $ line [LOA]   $ line [Price_Reduced] & lt; / TD & Gt; & lt; td & gt; $ line [Price_Previous] & lt; / TD & gt; & lt; td & gt; $ line [Amt_Reduced] & lt; / td> & lt; td & gt; $ Line [Amt_Pct]  gt; & lt; / tr & gt; \ n "; }  

No comments:

Post a Comment