date does not enter the mysql table

A

Anonymous

Guest
Hi all,

i have concatenated my date and time fields and trying to insert into two field names defined as DATETIME variable.But does not go through....

its not inserting into the table........At the end i changed the variables to "VARCHAR"......by which the problem was solved......

but i want to know if there is any other way to convert my date into DATETIME variable........as in mysql format ie

0000-00-00 00:00:00 form

please help.......
 
MySQL uses Unix timestamp, so you would have to format it accordingly.
anyways read THIS
To generate the timestamp mysql uses, you can do the following:
Code:
<?
$mysql_timestamp = date("YmdHis");
?>
Also read through the comments HERE, there are people that had similar problems there...
Hope all that helps...
 
Hi ,

Thank you very much for your response.Actually i did not understand how to use that "timestamp" but tried using this and got through.Here's how i did it...


Hope its correct in the long run :?



Code:
$now = time();

$anh =date("Y-m-d H:i:s a",$now); 

//$today=date("F j, Y, g:i a");

$sql="insert into taskdatetime(user_id,entertime,user_name)values('$sesuserid','$anh','$sesusername')";

$result=mysql_query($sql,$conn);
 
Back
Top