I wanne convert the mysql date to a nice one. I know how mysql saves there dates but they are ugly... I tryed some stuff i found on the net but it all didnt work out... its for a guest book
Here is my code of the display of the guestbook:
<?php require_once('db/db_connection.php'); $sql = "SELECT * FROM guestbook ORDER BY insertdate DESC"; $result = $MyDb->f_ExecuteSql($sql); $recordcount = $MyDb->f_GetSelectedRows(); ?> <h2>Gasten Boek</h2> <a href="add.php"><img src="images/reply.gif" height="17" width="107" border="0" /></a> <br /> <?php while ($row = $MyDb->f_GetRecord($result)) { ?> <table cellpadding="0" cellspacing="0" class="gb" border="0"> <tr height="15"> <td width="100"><?php echo $row['name']; ?></td> <td width="500" align="right"><?php echo $row['insertdate']; ?></td> </tr> <tr> <td width="100"></td> <td width="500"><?php echo nl2br($row['text']); ?></td> </tr> </table> <br /> <?php } ?>
Now here is the code where the date is saved to the mysql
<?php require_once('db/db_connection.php'); if (isset($_POST['submitBtn'])) { $name = (isset($_POST['name'])) ? htmlentities($_POST['name']) : ''; $comment = (isset($_POST['comment'])) ? htmlentities($_POST['comment']) : ''; $actDate = date("Y-m-j G:i"); //Minimum name and comment length. if ((strlen($name) > 2) && (strlen($comment) > 5)){ $sql = "INSERT INTO guestbook (name,text,insertdate) VALUES ("; $sql .= "'".$name."','".$comment."','".$actDate."')"; $MyDb->f_ExecuteSql($sql); } header("Location: index.php"); } else { ?>
This is the sql file i ran for my database:
CREATE TABLE `guestbook` ( `id` int(11) NOT NULL auto_increment, `name` varchar(100) default NULL, `text` text, `insertdate` datetime default NULL, `location` varchar(100) default NULL, `web` varchar(100) default NULL, `email` varchar(100) default NULL, PRIMARY KEY (`id`) );
If somebody can help me please tell me what i have to do and where i have to put what... I really dont know anything from php, total noob at it...
Thnx for the help
~Shub
Edited by shub, 27 July 2007 - 12:44 PM.