SauloA Posted January 24, 2007 Share Posted January 24, 2007 I have a MySQL database and I'm trying to set my datetime fields have a default value of NOW() or CURDATE or something that records the current date/time. I'm using phpmyadmin and input NOW() and a number of other default values in the default value text box, but I keep getting an error saying that my default value is invalid. Is there any way to set a default value that records the current date/time on phpMyAdmin or MySQL? I'd appreciate the help.Here's my table structure. The [color=red]red[/color] is the datetime field I'm trying to change.CREATE TABLE `user_review_tbl` ( `urev_id` int(11) NOT NULL auto_increment, `user_id` int(11) NOT NULL, `urev_review` text NOT NULL, [color=red]`urev_date` datetime NOT NULL,[/color] `urev_approved` tinyint(1) default NULL, `shop_id` int(11) NOT NULL, PRIMARY KEY (`urev_id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; Quote Link to comment Share on other sites More sharing options...
fenway Posted January 24, 2007 Share Posted January 24, 2007 We've all wanted that -- it's impossible to do. TIMESTAMPs sort of do that, but never use timestamps. Quote Link to comment Share on other sites More sharing options...
SauloA Posted January 24, 2007 Author Share Posted January 24, 2007 How else am I supposed to to get the current date and time then? If timestamps aren't recommended than what else is there. This forum records the current date and time when something is posted. How do I get the same results? Quote Link to comment Share on other sites More sharing options...
Daney11 Posted January 24, 2007 Share Posted January 24, 2007 No i dont think its possible.The forums use, i think.....$date = date("[url=http://uk2.php.net/date]http://uk2.php.net/date[/url]");$time = date("[url=http://uk2.php.net/date]http://uk2.php.net/date[/url]");To get the date and time and then it is inserted or updated into the relevant database. Quote Link to comment Share on other sites More sharing options...
fenway Posted January 25, 2007 Share Posted January 25, 2007 Just use NOW() as the column value when you run your inserts/updates like the rest of us do. Quote Link to comment 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.