Jump to content

Recommended Posts

I am have troubles displaying a date. I got the information from the database. Then I used the date() function.

 

This is how it looks:

 

$date = date('M j,Y' , $post_date);

 

the $post_date is from the database query

 

I defined it as $post_date = $row3['post_time'];

 

In the database I am using datetime for the post_time field

 

If you understand the mess I just said, do you know what I am doing wrong? And please show examples.

 

I did echo it, but when I did, it display Dec 31, 1969. The day should be Jul 9, 2010

Hello,

 

The datetime field stores the date and time as a string in the format "Y-m-d h:i:s A". As this is a string format, you can not format the date string without converting it back into a timestamp variable type.

 

Try the following

$post_date = strtotime($row3['post_time']);

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.