date does not enter the mysql table

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
sansoft
New php-forum User
New php-forum User
Posts: 44
Joined: Fri May 07, 2004 2:16 am
Location: India
Contact:

Mon May 17, 2004 8:33 am

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

Alex
New php-forum User
New php-forum User
Posts: 180
Joined: Fri Mar 07, 2003 4:59 pm
Contact:

Mon May 17, 2004 8:49 am

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: Select all

<?
$mysql_timestamp = date("YmdHis");
?>

Also read through the comments HERE, there are people that had similar problems there...
Hope all that helps...

sansoft
New php-forum User
New php-forum User
Posts: 44
Joined: Fri May 07, 2004 2:16 am
Location: India
Contact:

Tue May 18, 2004 2:23 am

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: Select all

$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);









Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests