PHP is really the wrong place for such a discovery. There are several reasons why this is a bad idea, and they are well documented in many places.
The key to successfully working with browser compatibility is finding support for the features you need and polyfill, or gracefully worsening those specific features. Finding the actual version of the browser or browser is bad practice and is likely to give you problems with both false positives and false negatives. Since the whole purpose of the exercise is to avoid glitch failures, the presence of inaccurate results makes all of this somewhat self-complete.
Modernizr is a great tool for discovering functions, but if you really disagree with this, as you say in this question, here is a tiny little JS function that specifically defines support for the type of a date input field:
function browserSupportsDateInput() { var i = document.createElement("input"); i.setAttribute("type", "date"); return i.type !== "text"; }
As you can see, it is really simple. (You can find it in more detail here , by the way)
With this feature, your site now becomes very easy to polyfill the date field.
Here is your HTML:
<input type='date' name='whatever' class='datepicker'>
Now you can have a small jQuery bit that does the following:
$(function() { if(!browserSupportsDateInput()) { $(".datepicker").datepicker(); } });
Just like that.
Of course, Modernizr will be better. Modernizr does not make polyfill itself, so you need a code similar to the one above to use the datepicker plugin if the date input type is not supported, but what Modernizr does, which I did not do in my code above, it allows you to tell the browser only to load datepicker libraries, if necessary. This will save a lot of bandwidth for modern browsers. Modernizr makes such things dead easy.
We hope that the above will give you some food for thought about the best way to do such things. All about best practice. If you feel that you should do this in PHP, then so be it, but just keep in mind that you go against the recommendation of almost all the experts there, and this will give you more headaches in the long run.