Link to home
Start Free TrialLog in
Avatar of dirtydinny
dirtydinny

asked on

displaying date using HTML

Is there any way of displaying the current date (and even time if possible) using HTML ONLY. Also while i'm at it is there any way of getting text (is actually a link which i got rid of its automatic underline) to be underlinked when the user hyover over it. This also MUST BE HTML ONLY. It can't have ANT JAVASCRIPT of CSS. I know you can do both of those using javascript and css but these must be HTML only. thanks

dinny
Avatar of avner
avner

NO.
HTML is static and you can not do what you are trying to do without Javascript or CSS .
Well,
 Here is how you underline your links when someone HOVERS your links.

a:link{
     background-color: transparent;
     color: #ffffff;
     text-decoration: none;
}
a:visited{
     background-color: transparent;
     color: #FFFFFF;
     text-decoration: none;
}
a:hover{
     background-color: transparent;
     color: #000080;
     text-decoration: underline;
}
a:active{
     background-color: transparent;
     color: #ffffff;
}

As far as i know you will have to use some sort of date script for your Date
And if you can`t use CSS

GO FIND ANOTHER WEB HOSTING COMPANY
Avatar of dirtydinny

ASKER

ok where do i add that code?? in the anchor tag for that link?????????
ok where do i add that code?? in the anchor tag for that link?????????
here is a complete example for the links

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
a:link{
    background-color: transparent;
    color: red;
    text-decoration: none;
}
a:visited{
    background-color: transparent;
    color: blue;
    text-decoration: none;
}
a:hover{
    background-color: transparent;
    color: yellow;
    text-decoration: underline;
}
a:active{
    background-color: transparent;
    color: green;
}
//-->
</style>

</head>

<body bgcolor="#FFFFFF" text="#000000">
<p><a href="http://cnn.com">Link 1</a></p>
<p><a href="https://www.experts-exchange.com">Link 2</a></p>
<p><a href="http://microsoft.com">Link 3</a></p>
</body>
</html>
And here is a full example with the date script
===============================================

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


<style type="text/css">
<!--
a:link{
    background-color: transparent;
    color: red;
    text-decoration: none;
}
a:visited{
    background-color: transparent;
    color: blue;
    text-decoration: none;
}
a:hover{
    background-color: transparent;
    color: yellow;
    text-decoration: underline;
}
a:active{
    background-color: transparent;
    color: green;
}
//-->
</style>

</head>

<body bgcolor="#FFFFFF" text="#000000">
<p><script type="text/javascript">
<!--
     var d=new Date()
var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
document.write(weekday[d.getDay()] + " ")
document.write(d.getDate() + ". ")
document.write(monthname[d.getMonth()] + " ")
document.write(d.getFullYear())
//-->
</script></p>
<p><a href="http://cnn.com">Link 1</a></p>
<p><a href="https://www.experts-exchange.com">Link 2</a></p>
<p><a href="http://microsoft.com">Link 3</a></p>
</body>
</html>
hey thats cheating i said no CSS. How about displaying the date (and or time ) with Javascript. Keep the code as simple and as short as possible

hey thats cheating i said no CSS. How about displaying the date (and or time ) with Javascript. Keep the code as simple and as short as possible

A short script to display the date :

<body>
<script>document.write(new Date().toLocaleString())</script>
</body>
This Does your Day, and Date
<script type="text/javascript">
<!--
    var d=new Date()
var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
document.write(weekday[d.getDay()] + " ")
document.write(d.getDate() + ". ")
document.write(monthname[d.getMonth()] + " ")
document.write(d.getFullYear())
//-->
</script>

And if you don`t want the links underlind at all you can do this

<a href="http://cnn.com" text-decoration:none>Link 1</a>
hey thats cheating i said no CSS. How about displaying the date (and or time ) with Javascript. Keep the code as simple and as short as possible

Just out of curiosity why don't you want to use CSS and Javascript?
sorry avner i did not see you posted
avner good code - i'll give you the points if you can get the date alone to appear. I think a static time on its own looks cheap. So a static date is good, consider i expect the code for a running clock to be tricky.
For a running time :
<html>
<head>
<title>abot:blank</title>
<script language="javascript1.2">
<!-- avcoh@yahoo.com
function setTime()
{
document.getElementById("time").innerText = new Date().toLocaleString()
}
function init()
{
var oInter = window.setInterval("setTime()",1000);
}
-->
</script>
<style>

</style>
</head>
<body onload="init()">
<div id="time"></div>
</body>
</html>

avner good code - i'll give you the points if you can get the date alone to appear. I think a static time on its own looks cheap. So a static date is good, consider i expect the code for a running clock to be tricky.
avner good code - i'll give you the points if you can get the date alone to appear. I think a static time on its own looks cheap. So a static date is good, consider i expect the code for a running clock to be tricky.
dirtydinny

Please do not use the Refresh Button in your browser,
use the Reload This Question on the top left of this web page.
avner good code - i'll give you the points if you can get the date alone to appear. I think a static time on its own looks cheap. So a static date is good, consider i expect the code for a running clock to be tricky.
Avatar of daleoran
Hi dirtydinny,
have no answers as they would be the same as above, but due to the time and effort put into the answers above how about bumping up the points - 20 is a miserable figure :)
ok if anyone has the code for the date alone ni'll give them all my points - 40points
has anonye got the code for the date alone?????? i'll give anyone the points. THe reason why its only 20 is that alll i have!! sorry
dirtydinny , I have already posted the code for the date, anything else you need ?
avner the code yuo gave was

<script>document.write(new Date().toLocaleString())<script>

this prints the time at the end of the date.
e.g  06 March 2003 11:53:33

all i want is 06 March 2003 - possible??

thanks
ASKER CERTIFIED SOLUTION
Avatar of avner
avner

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The best I have is javascript as follows, It gives the date as "dd/mm/yy" but can be changed to suit your area.

<body>
<script>
var t = new Date();
var mm = t.getMonth()+1;
var dd = t.getDate();
var yy = t.getYear();
var d;
if (mm < 10) mm="0"+mm;
if (dd < 10) dd="0"+dd;
if (yy > 1899 && yy< 2000) yy=yy-1000;
if (yy > 1999 && yy< 3000) yy=yy-2000;
if (yy > 2999 && yy< 4000) yy=yy-3000;
if (yy<10) yy="0"+yy;
d = dd + "-" + mm + "-" + yy;
document.write(d);
</script>
</body>