Hello,
Is there any method to show current date in meta title of a page in a html website ?
It will show date in tag?
What code I have to write, I don’ have any reference to write code.
I know how to write current date in a webpage using javascript but how to write date in title tag ?
<script><!--
var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday");
var monthNames = new Array(
"January","February","March","April","May","June","July",
"August","September","October","November","December");
var now = new Date();
document.write(
now.getDate() + " " +
monthNames[now.getMonth()] + ", " + now.getFullYear());
// -->
</script>
This is the code to show current date in a page, how to show in head section title…
What code I have to write please guide me
<!DOCTYPE html>
<html>
<head>
<title>My title</title>
</head>
<body onload="myFunction()">
<p>Click the button to display the title of the document.</p>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.title;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
See in this example it is showing title on a page using document.title https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_title
Whereas I want to show date in tag
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title> </title>
<meta name="description" content="There may be many reasons why you cannot login to webmail. Check your username and password.">
<script>
var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday");
var monthNames = new Array(
"January","February","March","April","May","June","July",
"August","September","October","November","December");
var now = new Date();
document.title(now.getDate() + " " + monthNames[now.getMonth()] + ", " + now.getFullYear());
var docTitle = document.title;
</script>
</head>
<body>
demo
</body>
</html>
Please help how to do it if you know this…