Jump to content

Can't make datetime field's default value NOW(), HELP.


SauloA

Recommended Posts

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 ;
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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