var dateDisplay1 = Date.parse(firstDate).toString("dd/MM/yyyy HH:mm");
There are a few issues here.
Parsing of date strings is largely implementation dependent, and where following standards, may produce inconsistent results. You should manually parse date strings, a library can help but a 2 line function will suffice if you only have one format and are sure it's a valid date (see below). To test for a valid date is only one extra line.
Date.parse returns a number, which is a time value, so Date.parse(...).toString() is calling Number.prototype.toString where the passed argument is a radix. So if Date.parse returns a suitable value, then:
new Date(Date.parse(...)).toString()
would be required.
If you wish to present the date string in a particular format, you can test for support for the internationalization API and use that and fall back to your own function (or just use your own), e.g.
function parseDMY(s) {
var b = s.split(/\D+/);
return new Date(b[2], b[1]-1, b[0], b[3], b[4], b[5]);
}
function formatDateDMYhm(d) {
// Use internationalization API if available
if (typeof Intl == 'object' && typeof Intl.DateTimeFormat == 'function') {
options = {
year: 'numeric', month: '2-digit', day: '2-digit',
hour: '2-digit', minute: '2-digit', /* second: '2-digit', */
hour12: false
};
return d.toLocaleString('en-GB', options);
}
// Otherwise, use bespoke function
function z(n){return (n<10? '0':'') + n}
return z(d.getDate()) + '/' + z(d.getMonth()) + '/' + d.getFullYear() +
' ' + z(d.getHours()) + ':' + z(d.getMinutes());
}
var firstDate ='13/11/2015 13:27:24';
var secondDate ='07/11/2015 13:19:45';
document.write(formatDateDMYhm(parseDMY(firstDate)) + '<br>');
document.write(formatDateDMYhm(parseDMY(secondDate)));
Though if the internationalisation API is used, it inserts an extra comma after the date in some browsers (e.g. Chrome) but not others (e.g. IE), so even using standards does not necessarily produce a "standard" result. Maybe it shouldn't be used in this case. Using the month name is much less ambiguous, so consider using that instead, e.g. 13-Nov-2015 13:27.