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
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?

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.