If your dates are strings in a strict yyyy-mm-dd
format as shown in the question then your code will work as is without converting to date objects or numbers:
if(first > second){
...will do a lexographic (i.e., alphanumeric "dictionary order") string comparison - which will compare the first characters of each string, then the second characters of each string, etc. Which will give the result you want...