I have a java script calendar control on my webpage for managing dates, in some time the date value is stored in my DB as "30/11/-0001".
It will be more appreciated if any one help me, please.....
The date you are trying to set is probably empty. I have the same issue with a Symfony2 project where DateTime's stored in SQL with a value of '0000-00-00 00:00:00' result in "30-11--0001" when parsed by Twig's date filter.
After 2 days i got the solution using notes on php.net:
Note: If the number of the year is specified in a two digit format, the values between 00-69 are mapped to 2000-2069 and 70-99 to 1970-1999. See the notes below for possible differences on 32bit systems (possible dates might end on 2038-01-19 03:14:07).
Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 UTC to Tue, 19 Jan 2038 03:14:07 UTC. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) Prior to PHP 5.1.0, 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. For 64-bit versions of PHP, the valid range of a timestamp is effectively infinite, as 64 bits can represent approximately 293 billion years in either direction.
because of this problem they are showing 01-01-1970 or 30-11--0001
So you may have to put Validation from where you taking inputs.
From My Side: I am taking Android side value so i have created Regular Expression for that.
You can test Regex here.
Hope it will helps you.
You need to do some testing on your front end and get the SQL statements that are constructed with different inputs and look at what's being inserted into the database. A malformed date in the SQL query may be the culprit for the db value you're seeing.
if (!empty($this->dob && $this->dob != '0000-00-00'))
{
$dob = date_format(date_create($this->dob), "d-m-Y");
} else {
$dob = '';
}
Add this condition to resolve this date issue $this->dob != '0000-00-00'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With