Skip to content
Advertisement

How to process insane date inputs with php

I have a code in php for processing the personal details of a person. I need code to handle the date input such that when the user inputs a year like 1900 and below then the program outputs That is impossible. I have successfully handled how the program should respond if the date input is in the future. The program takes date input from the user in the European Date Format for example 21-10-1990, Am having a hard time processing this because the php in-built function time() returns a unix timestamp measured since January 1st 1970. Is there a way I can circumvent this to achieve detection of years startimg from 1900 and below without applying a conditional structure to the year directly?

Code

JavaScript

Advertisement

Answer

Using DateTime instead of time() and strtotime()

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement