How to show real time, date, day in this format?
The time should be actual (which runs the seconds count).
Thanks guys!
Call the getDay() method on the Date object to get the day of the week. The getDay method returns the day of the week for the specific date, represented as an integer between 0 and 6 , where 0 is Sunday and 6 is Saturday.
You can do it like that: var d = new Date(); var month = d. getMonth()+1; var day = d. getDate(); var output = d.
HTML input type="week"
To update time panel every second we should use setInterval()
function.
To format date the way you need the best approach is to use moment.js
library. The code is shortened greatly:
$(document).ready(function() {
var interval = setInterval(function() {
var momentNow = moment();
$('#date-part').html(momentNow.format('YYYY MMMM DD') + ' '
+ momentNow.format('dddd')
.substring(0,3).toUpperCase());
$('#time-part').html(momentNow.format('A hh:mm:ss'));
}, 100);
});
Here is working fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With