I have a site where users provide some dates, but if they enter year like 12 april 2099, then the I get date in the past (1969). How do I check it and apply a default max safe date?
thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try the
DateTimeclassesNot sure what DateTime uses internally to store the timestamp instead of Integers. But Integers are limited by your platform’s value for
PHP_INT_MAX. You can test this with formatting the datetime with ‘U’ (for timestamp) and passing it todate():Notice how
DateTimereturns the correct timestamp butdatecannot work with it: