CipherIS
asked on
HTML Display Current Year
How can I change 2015 below to always display the current year?
<div style="text-align: center; margin-top: -3px">
Copyright 2015 My Company™. All Rights Reserved.
</div>
<div style="text-align: center; margin-top: -3px">
Copyright 2015 My Company™. All Rights Reserved.
</div>
ASKER
How about with javascript? I'm not using PHP so that won't work but thanks for the info.
Javascript could work, though at times can lead to NOSCRIPT errors and not load the year anyways, but you could try:
<p>© Copyright
<script language="JavaScript" type="text/javascript">
now = new Date
theYear=now.getYear()
if (theYear < 1900)
theYear=theYear+1900
document.write(theYear)
</script>
<p>© Copyright
<script language="JavaScript" type="text/javascript">
now = new Date
theYear=now.getYear()
if (theYear < 1900)
theYear=theYear+1900
document.write(theYear)
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is another Example using Java Script
<html>
<head>
<script language="JavaScript">
function mdy(todaysdate) {
//calls the function mdy why to get our date
return todaysdate.getMonth()+1+"/"+todaysdate.getDate()+"/"+todaysdate.getYear()
}
</script>
</head>
<body>
<script language="JavaScript">
sampleDate1=new Date()
document.write ("Today's date is "+ mdy(sampleDate1))
</script>
</body>
</html>
If you are willing to accept a non-HTML solution, almost all hosts now a days have PHP support built in. Simply change the extension of your HTML file to .php and add this one line in the area where you want it to display:
<?php echo date("Y"); ?>