+ 2
Challenge: Display the date of current week's Thursday...
Complete Challenge: Display the date of current week's Thursday in this format: DD/MM/YYYY, In Html using JS.
3 Respuestas
+ 1
Here is the right answer:
JS:
function Currentthursday() {
var d = new Date();
d.setDate(d.getDate() + 4 - d.getDay());
var monthe = 0;
monthe = (d.getMonth() + 1).toLocaleString('en-US', {minimumIntegerDigits: 2}) //js month starts from 0
return ( d.getDate().toLocaleString('en-US', {minimumIntegerDigits: 2}) + "/" + monthe + "/" + d.getFullYear());
//console.log(Currentthursday);
}
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Display Current Thursday's Date</h1>
<button type="button"
onclick="document.getElementById('currentthdate').innerHTML = Currentthursday()">
Click to Display</button>
<p id="currentthdate"></p>
</body>
</html>
https://code.sololearn.com/WSw8qjHo9orQ/#html
+ 6
I decided to do for you, here is the syntax ↓↓↓
function data() {
var x1 = new Date();
var a = x1.getFullYear();
var b = x1.getMonth();
var c = x1.getDay();
document.write(a + ":" + b + ":" + c);
}
setInterval(date, 1000);
0
James16, will your code work tomorrow? You missed the riddle in challenge. Also wheres the button's code and the format i want in.
Read the challenge again: Display the date of current week's Tuesday in this format: DD/MM/YYYY, In Html Show/Hide button.
Also carefully see, i want in 2 digits if it is January's 1. It should be like 01/01/2018 not 1/1/2018
Example: Consider making code for Friday of the current week. how will it show it? I have made an efficient code but i'll share after viewing some good codes and comparing with them.