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
https://forums.phpfreaks.com/topic/82702-solved-timestamp/
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
https://forums.phpfreaks.com/topic/82702-solved-timestamp/#findComment-420662
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
https://forums.phpfreaks.com/topic/82702-solved-timestamp/#findComment-420672
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.