Wednesday 15 June 2011

PHP: blog - how to add the date to a comment -


I am creating a simple PHP script to manage a blog, but I'm stack ..

It is now possible to include in a form right now: name, mail, content. And the comment will be displayed properly.

I would like to add every comment to the exact date and time of the comment.

I read about the date all afternoon () the time () and timestamp () but from me Do not get anything.

Someone can help me

Thanks!

The answer to this question is just right:

  $ Query = "Include terms (name, mail, content) values ​​('$- >-- ',' $ This-> mail ',' $ this- & gt; content ') ";    

Add a DATETIME column to your table. After you insert a comment, insert date ('Y-M-DH: I: S) in that column after that you can parse that time (if you want to make it YYYY-MM- DD wants to display HH: MM: SS format in any other way. There are some ways you can do some suggestions, Stormat and date or striptime functions or datetime class.

Update

  $ query = "Enter in Posts (Name, Mail, Content, Day Time) value ('$ this- & gt; name', '$ this- & gt; mail', '$ this- & gt; content', ". Date ('Ymd H: i: s).') ;    

No comments:

Post a Comment