I\'m having problems getting the date inserted properly into my database.
$date = date(\'m/d/Y h:i:s\', time());
I use this format, and, it
If you Pass date from PHP you can use any format using STR_TO_DATE()
mysql function .
Let conseder you are inserting date via html form
$Tdate = "'".$_POST["Tdate"]."'" ; // 10/04/2016
$Tdate = "STR_TO_DATE(".$Tdate.", '%d/%m/%Y')" ;
mysql_query("INSERT INTO `table` (`dateposted`) VALUES ('$Tdate')");
The dateposted
should be mysql date
type . or mysql will adds 00:00:00
in some case You better insert date and time together into DB so you can do calculation with hours and seconds . () .
$Tdate=date('Y/m/d H:i:s') ; // this to get current date as text .
$Tdate = "STR_TO_DATE(".$Tdate.", '%d/%m/%Y %H:%i:%s')" ;