Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi,
i'm having a table in mysql which has a column name DOB, the field of which defined as date. & i'm inserting the data into it, after converting the value receied in the form of text into date format using the following code...
$dte = date("Y-m-d", strtotime($dt));//the value in $dt is in the form "01-Dec-2003"
$db = mysql_connect("localhost");
mysql_select_db("deepa", $db);$sql = "insert into check values('$slno','$name','$dte')"
or die("could not execute query");
$result = mysql_query($sql);this piece of code executes fine except when the given date lies previous to year 1970.
for eg:
if the date value is given as "01-Jan-1970"..it works fine
but if the date value is given as "01-Jan-1969" or previous years...then it throws a warning as below & some junk gets inserted in to db.Warning: unexpected error in date() in c:\apache\htdocs\mscl\check_date\submit.php on line 12
please help me out with this problem...thanx already..
regards,
deepa

*We celebrate SN's first PHP answer*
This is a well-documented problem with strtotime() on windows:
"Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the unix epoch. This means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems. "
documentation is here.
I've traditionally used select/option lists for date entering, so there is less chance of error. Then, in php, with its magical form parsing, you can just say:
$dte=$year."-".$month."-".$day
(assuming year, month and day were the input fields for the birth date column)Good luck,
-SN

![]() |
what is pearl
|
End Statement in VB
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |