I was trying to display current date and time in a label control on my web page using JavaScript, but it seems to only show the time. The date does not show.
*The time updates itself accordingly. I just want to display the time with date
JavaScript
<script type="text/javascript">
$(document).ready(function () {
ShowTime();
});
function ShowTime() {
var dt = new Date();
document.getElementById("TimeandDate").innerHTML = dt.toLocaleTimeString();
window.setTimeout("ShowTime()", 1000); // Here 1000(milliseconds) means one 1 Sec
}
</script>
HTML
<label runat="server" id="TimeandDate"></label>
C#
protected void Page_Load(object sender, EventArgs e)
{
TimeandDate.InnerText = DateTime.Now.ToString("dddd, MMMM d, yyyy h:mm tt");
}