Jump to content

[SOLVED] timestamp


atticus

Recommended Posts

Hi all, I am trying to get a timestamp onto records as they are submitted into the mysql database.  I have field in mysql that is "timestamp" called time.

 

this is a portion of the php code I am using.  I don't think I am using the date() function correctly.  It doesn't error out but the timestamp in the database is all 0's.

 


$stamp = $date(Y-m-d,H-i-s);


 

I did not put this into the form, but created the variable after the form is submitted so the variable can go directly into the database.

Link to comment
Share on other sites

$query = "INSERT INTO `order` (type_service, notes, agree, time) 
VALUES ( '$type_service', '$notes', '$agree','NOW()');"; 

 

Hi, try this,remove the ' ' surrounding NOW():

 

$query = "INSERT INTO `order` (type_service, notes, agree, time) 
VALUES ( '$type_service', '$notes', '$agree',NOW());"; 

Link to comment
Share on other sites

Why wouldn't you just create a TIMESTAMP in the MySQL Database..???

Then you wouldn't have to include it in the script like this..

<?php
$query = "INSERT INTO `order` (type_service, notes, agree, time) 
VALUES ( '$type_service', '$notes', '$agree','NOW()');";
?>

 

You could just do this::

<?php
$query = "INSERT INTO `order` (type_service, notes, agree) 
VALUES ( '$type_service', '$notes', '$agree' );";
?>

 

And the NOW() would be taken care oif by the MySQL Column for each record...

 

Just a thought.......

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.