I have the following code which returns time and date, but I want to change the date format from mm/dd/yyyy
to dd/mm/yyyy
.
Can you change the format of the Date()
object below?
<script id="clockScript1" type="text/javascript">
var clockInterval;
$(function () {
if (clockInterval) return;
//add logo
var div1 = $('<div/>');
var logo = new Image();
logo.src = '/dashboardlogo.png'
logo.height = 60;
div1[0].style.margin = '10px auto';
div1.append(logo);
//add clock
var div2 = $('<div/>');
var p = $('<p/>');
div2.append(p);
div2[0].style.margin = '5px';
function displayTime() {
p.text(new Date().toLocaleString());
}
clockInterval = setInterval(displayTime, 1000);
//add to toolbar when it's available
var addToToolbarTimer;
function addToToolbar() {
var toolbar = $('.md-toolbar-tools');
if(!toolbar.length) return;
toolbar.append(div1);
toolbar.append(div2);
clearInterval(addToToolbarTimer);
}
addToToolbarTimer = setInterval(addToToolbar, 100);
});