I am currently learning my way around JavaScript and have a question about a function that I have which will generate a real time date and time for use in my application.
I'd like to format my JavaScript date to a specific UK format, as it currently is in US format.
My code currently looks like this
<a>
<script type="text/javascript">
document.write ('<p><span id="date">', new Date().toLocaleString(), '<\/span>.<\/p>')
if (document.getElementById) onload = function () {
setInterval ("document.getElementById ('date').firstChild.data = new Date().toLocaleString()", 50)
}
</script>
</a>
The above then displays as follows:
1/18/2019, 12:58:13 PM
Expected
UK format is DD/MM/YYYY so hence I want the date to be 18/1/2019
. The time is what I expected.