tags:

views:

143

answers:

4

I have table in mysql database which have field with datatype is datetime.

I want to save the datetime in this minute, for this I use " Now() ", but it does not work,

It just save 000000000000 in databaes.

A: 
INSERT ... (Now(), ...)

without additional quotes around the function Now()

VolkerK
A: 

date("g") this will return 12-hour format of an hour without leading zeros. For more options see http://php.net/manual/en/function.date.php

Aly
A: 

If you've got a timestamp in PHP check out FROM_UNIXTIME() http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtime

$tstamp = time();

$query = "INSERT INTO `table` VALUES (FROM_UNIXTIME($tstamp))";
preinheimer
A: 

I would use function time() too, then it's easy to output different kind of timestamps with date().

$query = "INSERT INTO tbl VALUES (".time().");";
Martti Laine