Jump to content

how to display date in dd-mm-yyyy


vivification
 Share

Go to solution Solved by aysiu,

Recommended Posts

Hi there,

 

I am still new to PHP and having trouble trying to format a date.

 

When the form data is saved; it is saved as YYYY-MM-DD.

 

Then, when you view a page to display all the records, it shows as YYYY-MM-DD.

I want to convert it to show DD-MM-YYYY.

 

The field name is "ETD" and "ETA".

 

Can I just use:

echo date("Y/m/d") ?

If so, how do I use it in the below scenario.

 

Would it be:

 

echo "<td>" . $row['etd']date("Y/m/d") . "</td>"; 

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td><a href='edit--report.php?id=" . $row['ID'] . "' >" . $row['ID'] . "</a></td>";
  echo "<td>" . $row['etd'] . "</td>";         
  echo "<td>" . $row['eta'] . "</td>";
  echo "</tr>";
  }
echo "</table>";


//mysqli_close($con);
?>

Would appreciate any help!

 

Thanks,

Link to comment
Share on other sites

Thanks hitman, but can you show me how I enter it on my code?

 

I dont understand how I need to enter/display it in my code.

Are they both on the same line? 

 

i.e.

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td><a href='edit--report.php?id=" . $row['ID'] . "' >" . $row['ID'] . "</a></td>";
  echo "<td>" . $date = new DateTime($row['etd']);
print $date->format('d-m-Y') "</td>";         
  echo "</tr>";
  }
echo "</table>";
Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

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