Skip to content
Advertisement

PHP checkdate variants

I found a php function checkdate() , but strangely enough it only seems to accept data in format of int $month , int $day , int $year. However I am passing the date as a string (example "2012-06-13") so I came up with this workaround, because I would only allow date entered in such format. Unfortunately I am feeling this is both insecure and not a nice approach to the problem:

JavaScript

Question: is there a better way to check whether the date is valid?

Advertisement

Answer

JavaScript

After several tests from both me and the people who tried to help me with my answer, I came up with this which suits me perfectly fine and is both easy and really reliable solution in my opinion as none was able to prove it wrong so far.

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