Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
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
Set the Date Format using JavaScript
WhatsApp
Gowtham K
Jul 10
2015
1.3
k
0
0
<html
xmlns=
"http://www.w3.org/1999/xhtml"
>
<head>
<script src=
"Scripts/jquery-2.1.4.min.js"
></script>
<link href=
"Content/bootstrap.min.css"
rel=
"stylesheet"
/>
<title>Javascript
set
date format </title>
</head>
<body >
<h3>Date Format</h3>
<br />
<form id=
"form1"
class
=
"form"
>
<div
class
=
"form-group"
>
<b>Current Date:</b>
<label id=
"Lbl_Curr_Date"
style=
"color:blue"
/>
</div>
<div
class
=
"form-group"
>
<b>dd mm yyyy format:</b>
<label id=
"Lbl_format_1"
style=
"color:blue"
/>
</div>
<div
class
=
"form-group"
>
<b>mm dd yyyy format </b>
<label id=
"lbl_format_2"
style=
"color:blue"
></label>
</div>
<div
class
=
"form-group"
>
<b>dd mm yyyy hh:mm:ss Format:</b>
<label id=
"lbl_format_3"
style=
"color:blue"
/>
</div>
</form>
</body>
</html>
<script type=
"text/javascript"
>
$(document).ready(function()
{
var today =
new
Date()
document.getElementById(
'Lbl_Curr_Date'
).innerHTML = today;
document.getElementById(
'Lbl_format_1'
).innerHTML = [today.getDate(), today.getMonth() + 1, today.getFullYear()].join(
'/'
);
document.getElementById(
'lbl_format_2'
).innerHTML = [today.getMonth() + 1, today.getDate(), today.getFullYear()].join(
'/'
);
document.getElementById(
'lbl_format_3'
).innerHTML = [today.getDate(), today.getMonth() + 1, today.getFullYear()].join(
'/'
) +
' '
+ [today.getHours(), today.getMinutes(), today.getSeconds()].join(
':'
);
})
</script>
javascript
Set the Date Format
Up Next
Set the Date Format using JavaScript