Jump to content

I need help retrieving dates from MySQL...


CrazeD

Recommended Posts

I have my date in MySQL, but I need to retrieve it. I'm making some forums, I need it to say when the post was submitted....which I can INSERT it, just can't get it back. It keeps putting the current date for all the posts, not the date in which they were entered.

 

$date_entered = time ($post_row['date_entered']);
$timestamp = date ('D M j, Y h:i A', $date_entered);

 

$post_row refers to my SELECT query, where it gets the date in the MySQL table.

 

This code here just outputs the current date/time, not what's in the database.

 

 

Can anyone help? Thanks.

Link to comment
https://forums.phpfreaks.com/topic/60391-i-need-help-retrieving-dates-from-mysql/
Share on other sites

if you just want a formatted version of the date, you can grab that directly through MySQL using the DATE_FORMAT() function.  see the MySQL manual's entry on functions and operators (section 13ish i think).  there are a slew of built-in functions that are very handy when pulling info from the database.

 

as for when you're inserting it, are you using PHP to insert the value, or are you using MySQL's NOW() function?

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.