this question has answer here:
- format date database? 5 answers
this easy 1 can't right.
i have following code , running ok. dates stored in mysql database in yyyy-mm-dd format on webpage, i'd display dates in format used in country (dd.mm.yyyy).
how modify code that?
$strsql = "select distinct date, information, additionalinformation tablename code='something' order date asc"; $rs = mysql_query($strsql); while($data=mysql_fetch_array($rs)) { echo ' <tr> <td>'.$data[date].'</td> <td>'.$data[information].'</td> <td>'.$data[additionalinformation].'</td> </tr> '; };
instead of doing in php can in mysql below:
$strsql = "select distinct date,date_format(date', '%y %m %d') desire_date, information, additionalinformation tablename code='something' order date asc"; $rs = mysql_query($strsql); while($data=mysql_fetch_array($rs)) { echo ' <tr> <td>'.$data['desire_date'].'</td> <td>'.$data['information'].'</td> <td>'.$data['additionalinformation'].'</td> </tr> '; }; you can find more info on mysql
Comments
Post a Comment