Can someone please help:(. I have a database with a field Date. I made the datatype to Date. But when I code the date in php I use the date() function to get the current date it donesn't want to insert in the database. Please help.

For example my code.

$name = $_POST['name'];
$date = date("yyyy,mm,dd");

insert into tablename ('name','date') values ('{$name}','{$date}');

Can someone please help:(. I have a database with a field Date. I made the datatype to Date. But when I code the date in php I use the date() function to get the current date it dones want to insert in the database. Please help.

For example my code.

$name = $_POST;
$date = date("yyyy,mm,dd");

insert into tablename ('name','date') values ('{$name}','{$date}');

no need of date field
just copy like this.

insert into tablename ('name','date') values ('{$name}',now());

take date in datebase

Can someone please help:(. I have a database with a field Date. I made the datatype to Date. But when I code the date in php I use the date() function to get the current date it donesn't want to insert in the database. Please help.

For example my code.

$name = $_POST;
$date = date("yyyy,mm,dd");

insert into tablename ('name','date') values ('{$name}','{$date}');

use it this way -

date('Y,m,d');
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.