Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Trainings
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Display current date & time at runtime into DIV tag
WhatsApp
Ghanashyam Nayak
5y
36.2
k
0
0
25
Blog
<Html>
<Head>
<Tile>
Sample Code</titel>
<Script type=
"text/javascript"
>
function
DisplayDateTime()
{
var
DateTime =
new
Date();
var
strYear= DateTime.getYear();
var
strMonth= DateTime.getMonth() +1;
var
strDay = DateTime.getDate();
var
strHours = DateTime.getHours();
var
strMinutes = DateTime.getMinutes();
var
strSeconds = DateTime.getSeconds();
var
tagDiv=document.getElementById(
"DivTag"
);
tagDiv.innerText =
"DD/MM/YYYY HH:MM:SS"
;
tagDiv.innerText = strDay +
"/"
+ strMonth +
"/"
+ strYear +
" "
+ strHours +
":"
+ strMinutes +
":"
+ strSeconds;
}
</Script>
</Head>
<Body bgcolor=#00ff00>
<H3>DD/MM/YYYY HH:MM:SS</H3>
<input type=
"button"
value=
"click"
onclick=
"DisplayDateTime();"
>
<H1>
<Div id=
"DivTag"
></div>
</H1>
</Body>
</Html>
People also reading
Membership not found