SERVER-13760 Do not call dateToISOString if date is not formatable
(cherry picked from commit 99fa4e6058a24d6c4d7fde19ce940719c5bbc210)