When I pass '7.12.60' to strtotime, it returns timestamp of today! I know strtotime guesses the format of the given string but here the value is not correct at all! it just returns today's timestamp:
echo date( 'Y-m-d', strtotime('7.12.60') ); // outputs 2022-01-05!
What i expect is to receive a false or a correct value and not a made up one
CodePudding user response:
As mentioned in comments of @aynber and others. It was considering it as a time and not a date, I added a time (00:00:00) to the end of the string and now it is returning false.
Thank you very much for your help
CodePudding user response:
The spelling of your date is not clear. What should '7.12.60' represent? 2060/12/07 or 1960/12/07 or 1860/12/07? You have to deliver the year number in 4 digits so that strtotime recognizes it correctly.
date_create_from_format() does not offer a solution here either, because for 'y', the two-digit representation of a year, it is assumed that it lies in the range from 1970 up to and including 2069.
If you need a different interval for the interpretation of two-digit year numbers, you have to redefine this and modify the input accordingly.
