Clicking one popup closes the other, fixed date formatting function