TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Set the Date Format using JavaScript
Gowtham K
Jul 10
2015
Code
1.3
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
<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