Originally Posted by Old Pedant
I think we have to assume he stole...err...copied...a dateFormat() function from someplace.
Which will not help the next person coming here searching for an answer to the same question as there still isn't an actual complete solution to the question published.
. Then you can easily extract just the date portion using the appropriate methods.
Neither version of the code the OP posted would work if the person entered "noon yesterday" as their date and time even though the code they have would allow that input.