Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

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
0
dirtydinny
Asked:
dirtydinny
  • 12
  • 8
  • 5
  • +2
1 Solution
 
avnerCommented:
NO.
HTML is static and you can not do what you are trying to do without Javascript or CSS .
0
 
jaysolomonCommented:
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
0
 
jaysolomonCommented:
And if you can`t use CSS

GO FIND ANOTHER WEB HOSTING COMPANY
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dirtydinnyAuthor Commented:
ok where do i add that code?? in the anchor tag for that link?????????
0
 
dirtydinnyAuthor Commented:
ok where do i add that code?? in the anchor tag for that link?????????
0
 
jaysolomonCommented:
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="http://experts-exchange.com">Link 2</a></p>
<p><a href="http://microsoft.com">Link 3</a></p>
</body>
</html>
0
 
jaysolomonCommented:
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="http://experts-exchange.com">Link 2</a></p>
<p><a href="http://microsoft.com">Link 3</a></p>
</body>
</html>
0
 
dirtydinnyAuthor Commented:
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

0
 
dirtydinnyAuthor Commented:
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

0
 
avnerCommented:
A short script to display the date :

<body>
<script>document.write(new Date().toLocaleString())</script>
</body>
0
 
jaysolomonCommented:
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>
0
 
dirtydinnyAuthor Commented:
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

0
 
jaysolomonCommented:
Just out of curiosity why don't you want to use CSS and Javascript?
0
 
jaysolomonCommented:
sorry avner i did not see you posted
0
 
dirtydinnyAuthor Commented:
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.
0
 
avnerCommented:
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>

0
 
dirtydinnyAuthor Commented:
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.
0
 
dirtydinnyAuthor Commented:
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.
0
 
jaysolomonCommented:
dirtydinny

Please do not use the Refresh Button in your browser,
use the Reload This Question on the top left of this web page.
0
 
dirtydinnyAuthor Commented:
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.
0
 
daleoranCommented:
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 :)
0
 
dirtydinnyAuthor Commented:
ok if anyone has the code for the date alone ni'll give them all my points - 40points
0
 
dirtydinnyAuthor Commented:
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
0
 
avnerCommented:
dirtydinny , I have already posted the code for the date, anything else you need ?
0
 
dirtydinnyAuthor Commented:
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
0
 
avnerCommented:
Sure thing :
<script>document.write(new Date().toLocaleDateString())</script>

Remember that the date is printed according to the client's regional settings.
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
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>
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 12
  • 8
  • 5
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now