Jump to content


Photo

Need Help With The Date And Time Thing.


  • Please log in to reply
3 replies to this topic

#1 psyion

psyion
  • Members
  • PipPip
  • Member
  • 13 posts
  • LocationKota Kinabalu, Sabah, Malaysia.

Posted 29 June 2006 - 05:37 AM

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'); ?>
<?php
function 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...nsitional.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">&nbsp;</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>&nbsp;</p>
</body>
</html>

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 29 June 2006 - 05:42 AM

copy and past exspert are you lol

nice 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">

?>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 psyion

psyion
  • Members
  • PipPip
  • Member
  • 13 posts
  • LocationKota Kinabalu, Sabah, Malaysia.

Posted 29 June 2006 - 07:39 AM

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

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 29 June 2006 - 07:43 AM

[!--quoteo(post=389148:date=Jun 29 2006, 07:39 AM:name=psyion)--][div class=\'quotetop\']QUOTE(psyion @ Jun 29 2006, 07:39 AM) View Post[/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]
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users