Jump to content

[SOLVED] Displaying time


Lambneck

Recommended Posts

Hi, I have the time recorded in a mysql database as timestamp yyyy-mm-dd hh:mm:ss format. When trying to display it I am using the following:

<?php echo date("M dS, Y", $row['date']); ?>

 

Unfortunately this outputs "Dec 31st 1969" for all database entries.

What the heck am I doing wrong here?

 

Link to comment
https://forums.phpfreaks.com/topic/162883-solved-displaying-time/
Share on other sites

<?php echo date("M dS, Y", strtotime(row['date'])); ?>

 

or, when you run the query just do

SELECT *, UNIX_TIMESTAMP(date) AS date .....

 

OR just do this and be done with it completely,

 

SELECT *, DATE_FORMAT(date, '%b %D, %Y') AS date .... 
<?php echo $row['date'] ?>

 

 

 

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.