Answer the question
In order to leave comments, you need to log in
Adding date and time to project?
I'm just starting to deal with js, the experience is almost zero, I added a script to the project to call the date and time
(function () {
window.isimple=window.isimple || {}
window.isimple.dates=window.isimple.dates || {}
window.isimple.dates.getCurrentDate=function () {
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth() + 1;
var curr_year = d.getFullYear();
return (curr_year + "." + curr_month + "." + curr_date);
}
window.isimple.dates.getCurrentTime=function () {
var d = new Date();
var curr_hours = d.getHours();
var curr_minutes = d.getMinutes();
return (curr_hours + ":" + curr_minutes);
}
})();
<label value="isimple.dates.getCurrentDate()"/>
Answer the question
In order to leave comments, you need to log in
I think you should do it like this:
<label id="labelOne" for=""></label>
<label id="labelTwo" for=""></label>
'use strict';
;(function () {
var labelOne = document.getElementById('labelOne'),
labelTwo = document.getElementById('labelTwo');
window.isimple=window.isimple || {};
window.isimple.dates=window.isimple.dates || {};
window.isimple.dates.getCurrentDate=function () {
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth() + 1;
var curr_year = d.getFullYear();
return (curr_year + "." + curr_month + "." + curr_date);
}
labelOne.innerHTML = window.isimple.dates.getCurrentDate();
window.isimple.dates.getCurrentTime=function () {
var d = new Date();
var curr_hours = d.getHours();
var curr_minutes = d.getMinutes();
return (curr_hours + ":" + curr_minutes);
}
labelTwo.innerHTML = window.isimple.dates.getCurrentTime();
})();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question