Jump to content

Turning date fields into actual dates


downah

Recommended Posts

I have got a date field in my mysql database with events, and as you know date in MYSQL uses yyyy/mm/dd but I would first like to turn this around to dd/mm/yyyy but also turn this into for example "Tuesday - May 1990" would anyone like to point me into the right direction?

 

Much appreciated!

Link to comment
https://forums.phpfreaks.com/topic/259866-turning-date-fields-into-actual-dates/
Share on other sites

Thanks for the help, at the moment I am first trying to turn yyyy/mm/dd around to dd/mm/yyyy with this:

 

$date = $row['eventdate'];

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

 

which puts it into dd/mm/yyyy great! although it is not showing the right dates! but automatically all dates seemed to change to 01/01/1970.. know why?

I got it to work using:

 

  echo "<td>"; 
print date('d M Y', strtotime($row['eventdate']));
echo " ";
echo $row['starttime'] . "</td>";

 

Thanks guys, although I'd still like to know why this doesn't work if anyone could point that out?

 

$date = $row['eventdate'];
$my_date = strtotime($date); 


  echo "<td>" . date('d-m-Y',$my_date) . " " . $row['starttime'] . "</td>";

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.