atticus Posted December 21, 2007 Share Posted December 21, 2007 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 More sharing options...
revraz Posted December 21, 2007 Share Posted December 21, 2007 Do you want date and time or just time? You can use the mysql NOW() function if you want date and time. Link to comment https://forums.phpfreaks.com/topic/82702-solved-timestamp/#findComment-420646 Share on other sites More sharing options...
atticus Posted December 21, 2007 Author Share Posted December 21, 2007 I want date and time, or at least date. Link to comment https://forums.phpfreaks.com/topic/82702-solved-timestamp/#findComment-420647 Share on other sites More sharing options...
atticus Posted December 21, 2007 Author Share Posted December 21, 2007 alright, I added it into my query, but still getting same results: $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-420660 Share on other sites More sharing options...
freebsdntu Posted December 21, 2007 Share Posted December 21, 2007 $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 More sharing options...
atticus Posted December 21, 2007 Author Share Posted December 21, 2007 you are a genius...thanks Link to comment https://forums.phpfreaks.com/topic/82702-solved-timestamp/#findComment-420665 Share on other sites More sharing options...
freebsdntu Posted December 21, 2007 Share Posted December 21, 2007 you are a genius...thanks LOL, you are over-praising me, I am just a php starter. Link to comment https://forums.phpfreaks.com/topic/82702-solved-timestamp/#findComment-420668 Share on other sites More sharing options...
PHPNewbie55 Posted December 21, 2007 Share Posted December 21, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.