Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dates setting to default '1999-11-30'

Tags:

php

mysql

My dates in mysql database are setting to 1999-11-30 no matter what I enter from my php form.

$degree_date = date("Y-m-d", mktime(0,0,0,$dt,$mo,$yr));
$other_degree_date = date("Y-m-d", mktime(0,0,0,$dty,$moy,$yry));
$expd_degree_date = date("Y-m-d", mktime(0,0,0,$dti,$moi,$yri));

Examples:

1. Date of Award
<select input name="dt" type="text" id="dt">
<select input name="mo" type="text" id="mo">
<select input name="yr" type="text" id="yr">
2. Date of Award
<select input name="dty" type="text" id="dty"> 
<select input name="moy" type="text" id="moy">
<select input name="yry" type="text" id="yry">
3. Date of Award
<select input name="dti" type="text" id="dti">
<select input name="moi" type="text" id="moi">
<select input name="yri" type="text" id="yri">

Insert statement:

$sql_insert = "INSERT into `acadmic`
`degree_date`,`other_degree_date`, `expd_degree_date` 
)
VALUES
'$degree_date', '$other_degree_date','$expd_degree_date',

I am getting messages that $dt $mo $yr etc aren't defined Any help?

like image 839
user1257518 Avatar asked Dec 07 '22 15:12

user1257518


1 Answers

A google search for "'1999-11-30' mysql php" came up with a non-bug on the first hit to explain why "1999-11-30" could be your result:

There is no bug here, 00-00-00 means 2000-00-00, which is 1999-12-00, which is 1999-11-30. No bug, perfectly normal.

I tested echo date("Y-m-d", mktime(0,0,0,0,0,0)) and that does print out 1999-11-30 as described in the reported PHP bug.

You may want to investigate whether your variables ($dt,$mo,$yr) actually have the correct values set from the form to begin with.

like image 154
Chris Baclig Avatar answered Dec 09 '22 05:12

Chris Baclig