Jump to content

The usual date format problem Yes I have read the previous posts


Voodoo Jai

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.