There are multiple libraries (Date.js, moment.js and others) that take care of this...
Also, it is easy to find googling, please do due dilligence next time before asking.
If you want your own function write it. Something like this:
<script type="text/javascript">
var d = new Date();
var curr_day = d.getDate();
var curr_month = d.getMonth() + 1;
var curr_year = d.getFullYear();
document.write(curr_day+ "/" + curr_month + "/" + curr_year);
</script>
There are getHour and others to get however precise value you need.
If this helps please take time to accept the solution.