PDA

View Full Version : INSERTing time();


assassingod
11-30-2003, 07:23 AM
Im inserting current time into the database, and the first time it worked. But now it just inserts 00000000000000 (But now every single one is 20031130084338)

How can I sort this problem out? It's quite annoying since when listing it on a another page, I get:

Warning: unexpected error in date() in c:\localhost\www\testforum\admin\functions.php on line 1738

sabret00the
11-30-2003, 08:00 AM
in your query try inserting is as

time = '".NOW()."'");

assassingod
11-30-2003, 08:11 AM
Doesn't work. (Don't think that's even a function)

sabret00the
11-30-2003, 08:16 AM
yeah it is ;)

how are you trying to enter it into the database

it depends on what information you're trying to enter really

if you want the time as well as the date and what not. although to enter is into the db you should have to concatenate is as above.

assassingod
11-30-2003, 08:22 AM
I've got it now thanks. I made an error when writing my create table query. (And I get undefined function error with now, so i' used time;))

Thanks anyways sabe:)

sabret00the
11-30-2003, 08:23 AM
sorry i weren't more intelligent :)

Dean C
11-30-2003, 10:08 AM
I normally use a mysql field called timestamp - so then i don't have to worry about it all as mysql does it automatically :)

assassingod
11-30-2003, 10:32 AM
I was originally using timestamp(14) but chaning to int(10) UNSIGNED, it worked fine:)

NTLDR
11-30-2003, 04:46 PM
in your query try inserting is as

time = '".NOW()."'");

Your almost right:

time = NOW()

Should work, as should:

time = ".time()."

or

time = $timenow

assassingod
11-30-2003, 05:03 PM
yeah ive used time() now.

FleaBag
12-01-2003, 05:06 AM
Hmm this is what I need too.

Though I am very confused LOL.

FleaBag
12-04-2003, 05:42 AM
Got it sorted, seems inserting now(); into a tinytext field is the easiest option - at least for me!