Voodoo Jai Posted March 9, 2008 Share Posted March 9, 2008 From my db I take a field $row_Takeaway['Rating_Date'] and want to assign it to the usual DMY format how do I assign it to a variable so that it can be changed. <br/> on the <?php echo $row_Takeaway['Rating_Date']; ?> this may have changed since the last inspection.</p> <?PHP //finding the sys date $correctdisplay=date('d-m-Y H:i:s'); echo $correctdisplay." system date."; ?> how do assign $row_Takeaway['Rating_Date'] to the variable $correctdisplay like the system date to show the format I want. Many thanks in advance for: I bet a simple annoying problem. Voodoo Jai Quote Link to comment Share on other sites More sharing options...
Voodoo Jai Posted March 9, 2008 Author Share Posted March 9, 2008 I have found a conversion snippet of code as follows, but it just displays the results as taken from the db. <?php $mydate=$row_Takeaway['Rating_Date']; function converttomysqlDate($mydate) { list($dd,$mm,$yy)=explode(".",$mydate); if (is_numeric($yy) && is_numeric($mm) && is_numeric($dd)) { return "$yy-$mm-$dd"; } } echo $mydate." mydate variable <br/>"; $mydate=$row_Takeaway['Rating_Date']; function converttosimpleDate($mydate) { list($yy,$mm,$dd)=explode("-",$mydate); if (is_numeric($yy) && is_numeric($mm) && is_numeric($dd)) { return "$dd.$mm.$yy"; } } echo $mydate." RatingDate variable"; ?> one function is supposed to convert yyyy-mm-dd to dd-mm-yyyy and the other dd-mm-yyyy to yyyy-mm-dd, why cant I get it working. Where am I going wrong. Thanks again Quote Link to comment Share on other sites More sharing options...
Voodoo Jai Posted March 10, 2008 Author Share Posted March 10, 2008 Got it figured out I was not calling the functiom properlyit should have been like this echo converttosimpleDate($mydate); Hope this helps someone else. Voodoo Jai Quote Link to comment Share on other sites More sharing options...
fenway Posted March 10, 2008 Share Posted March 10, 2008 Use DATE_FORMAT() -- a mysql function. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.