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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.