Tjorriemorrie Posted March 24, 2008 Share Posted March 24, 2008 Hey, I have a table Comments and a recordset rsComments for that table. I want to show the comment with the date it was submitted. <?php do { ?> <p class="commenter"><?php echo $row_rsComments['name']; ?> said: <span class="CommentDate"><?php echo " (on ".date("d M y", $row_rsComments['CommentDate']).")"; ?></span></p> <p class="commentleft"><?php echo $row_rsComments['comment']; ?></p> <p> </p> <?php } while ($row_rsComments = mysql_fetch_assoc($rsComments)); ?> Somehow when I test it it always returns 1 Jan 1970. Please take note I'm not familiar with php date() function PS: the CommentDate field is timestamp in MySQL, is that ok? The value lookin in phpMyAdmin shows 2008-03-24 21:16:20. Can anyone help me with this? Link to comment https://forums.phpfreaks.com/topic/97670-date-formatting/ Share on other sites More sharing options...
rhodesa Posted March 24, 2008 Share Posted March 24, 2008 I think you are looking for: <?php while ($row_rsComments = mysql_fetch_assoc($rsComments)) { ?> <p class="commenter"><?php echo $row_rsComments['name']; ?> said: <span class="CommentDate"><?php echo " (on ".date("d M y", strtotime($row_rsComments['CommentDate'])).")"; ?></span></p> <p class="commentleft"><?php echo $row_rsComments['comment']; ?></p> <p> </p> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/97670-date-formatting/#findComment-499752 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.