psyion Posted June 29, 2006 Share Posted June 29, 2006 i need to insert the current date and time of an entry into my database. how can i do this?in the last feaw lines of my script you can fine " <input type="hidden" name="timedate" value="">" what do i put for the value="" part? [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] below is my script (generated by Dreamweaver) [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] <?php require_once('Connections/msgBoard.php'); ?><?phpfunction GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}$editFormAction = $_SERVER['PHP_SELF'];if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);}if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO enquiry (name, email, timedate, msg) VALUES (%s, %s, %s, %s)", GetSQLValueString($_POST['name'], "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['timedate'], "date"), GetSQLValueString($_POST['msg'], "text")); mysql_select_db($database_msgBoard, $msgBoard); $Result1 = mysql_query($insertSQL, $msgBoard) or die(mysql_error());}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Name:</td> <td><input type="text" name="name" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Email:</td> <td><input type="text" name="email" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right" valign="top">Msg:</td> <td><textarea name="msg" cols="50" rows="5"></textarea> </td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Insert record"></td> </tr> </table> <input type="hidden" name="timedate" value=""> <input type="hidden" name="MM_insert" value="form1"></form><p> </p></body></html> Quote Link to comment https://forums.phpfreaks.com/topic/13178-need-help-with-the-date-and-time-thing/ Share on other sites More sharing options...
redarrow Posted June 29, 2006 Share Posted June 29, 2006 copy and past exspert are you lolnice code.[code]<?$the_date=date("d:m:y");$the_time=date("h:i:s");< input type="hidden" name="the_date">< input type="hidden" name="the_time">?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13178-need-help-with-the-date-and-time-thing/#findComment-50697 Share on other sites More sharing options...
psyion Posted June 29, 2006 Author Share Posted June 29, 2006 Thanks!hmmm... now i got the idea of the code... but, how do i change this and print it out as my local GMT? GMT+8:00 is my area Quote Link to comment https://forums.phpfreaks.com/topic/13178-need-help-with-the-date-and-time-thing/#findComment-50718 Share on other sites More sharing options...
redarrow Posted June 29, 2006 Share Posted June 29, 2006 [!--quoteo(post=389148:date=Jun 29 2006, 07:39 AM:name=psyion)--][div class=\'quotetop\']QUOTE(psyion @ Jun 29 2006, 07:39 AM) [snapback]389148[/snapback][/div][div class=\'quotemain\'][!--quotec--]Thanks!hmmm... now i got the idea of the code... but, how do i change this and print it out as my local GMT? GMT+8:00 is my area[/quote]i think it a o but check ok[a href=\"http://uk.php.net/date\" target=\"_blank\"]http://uk.php.net/date[/a] Quote Link to comment https://forums.phpfreaks.com/topic/13178-need-help-with-the-date-and-time-thing/#findComment-50722 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.