views:

62

answers:

2

Please i want to Insert data date in "textbox" with PHP to myssql. But i can't do it. And show it with format "dd/mm/yyyy" in table

A: 

Use the date function: http://www.php.net/manual/en/function.date.php You have good examples at the manual page.

For parsing a date, you can use strtok: http://www.php.net/manual/en/function.strtok.php or explode: http://www.php.net/manual/en/function.explode.php

Notinlist
A: 

As for formating the date, you can aswell format it within mysql query when returning it:

SELECT DATE_FORMAT(date, '%d %m %Y') FROM data;

DATE_FORMAT is a very nice feature.

Prix
but i have two field. field 1: name, field 2: day of birth. i used followInsert into customer("name","DOB") values ("$txtname","$txtDOB").result Field 2: 0000-00-00.Please!
Vuong Mao
`INSERT INTO customer ('name', 'DOB') VALUES ('$name', DATE_FORMAT($txtDOB,'%Y-%m-%d'))` OR `INSERT INTO customer ('name', 'DOB') VALUES ('$name', STR_TO_DATE($txtDOB,'%Y-%m-%d'))`
Prix
i see! please! in Mysql format field 2: Dateif i do INSERT INTO customer ('name', 'DOB') VALUES ('$name', DATE_FORMAT($txtDOB,'%Y-%m-%d')). but i can't insert it.
Vuong Mao
`or die mysql_error()` says what ?
Prix