Jump to content

HH:MM:SS to HH:MM


NealeWeb

Recommended Posts

I have a guestbook and i want to record and display the time of each post but at the moment all the times are added to the database including seconds so it looks like this - 05:42:33, i just want the hours and minutes like this - 05:42.

 

This is the code that adds the time.

$time = date("HH:MM");

 

$db = mysql_connect($dbHost,$dbUser,$dbPass);

mysql_select_db($dbname,$db);

 

$sql="INSERT INTO guestbook (`time`)

VALUES (

 

And this is the code that displays it

<?php

 

$db = mysql_connect($dbHost,$dbUser,$dbPass);

mysql_select_db($dbname,$db);

 

 

$requete = " time FROM guestbook ORDER BY ID desc LIMIT 1";

$result = mysql_query ($requete,$db);

 

while($row = mysql_fetch_assoc($result))

{

 

$time = $row["time"];

 

echo '<span class="font2">'.''.$time.''.'</span>';

 

}

?>

 

Can anybody help me.

 

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.