?
Solved

displaying date using HTML

Posted on 2003-03-05
27
Medium Priority
?
187 Views
Last Modified: 2010-04-09
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
Comment
Question by:dirtydinny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 8
  • 5
  • +2
27 Comments
 
LVL 14

Expert Comment

by:avner
ID: 8071485
NO.
HTML is static and you can not do what you are trying to do without Javascript or CSS .
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 8071531
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
 
LVL 16

Expert Comment

by:jaysolomon
ID: 8071536
And if you can`t use CSS

GO FIND ANOTHER WEB HOSTING COMPANY
0
Tutorial: Introduction to Managing a Linux Server

In this tutorial on systemd, we will explore:
-OS/Distro Adoption
-chkconfig and Other Legacy Commands
-Summary and Key Commands

 

Author Comment

by:dirtydinny
ID: 8071576
ok where do i add that code?? in the anchor tag for that link?????????
0
 

Author Comment

by:dirtydinny
ID: 8071593
ok where do i add that code?? in the anchor tag for that link?????????
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 8071717
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
 
LVL 16

Expert Comment

by:jaysolomon
ID: 8071760
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
 

Author Comment

by:dirtydinny
ID: 8072167
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
 

Author Comment

by:dirtydinny
ID: 8072214
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
 
LVL 14

Expert Comment

by:avner
ID: 8072226
A short script to display the date :

<body>
<script>document.write(new Date().toLocaleString())</script>
</body>
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 8072249
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
 

Author Comment

by:dirtydinny
ID: 8072261
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
 
LVL 16

Expert Comment

by:jaysolomon
ID: 8072264
Just out of curiosity why don't you want to use CSS and Javascript?
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 8072306
sorry avner i did not see you posted
0
 

Author Comment

by:dirtydinny
ID: 8072379
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
 
LVL 14

Expert Comment

by:avner
ID: 8072431
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
 

Author Comment

by:dirtydinny
ID: 8072435
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
 

Author Comment

by:dirtydinny
ID: 8072563
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
 
LVL 16

Expert Comment

by:jaysolomon
ID: 8072625
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
 

Author Comment

by:dirtydinny
ID: 8072818
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
 
LVL 10

Expert Comment

by:daleoran
ID: 8078958
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
 

Author Comment

by:dirtydinny
ID: 8078981
ok if anyone has the code for the date alone ni'll give them all my points - 40points
0
 

Author Comment

by:dirtydinny
ID: 8078988
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
 
LVL 14

Expert Comment

by:avner
ID: 8079002
dirtydinny , I have already posted the code for the date, anything else you need ?
0
 

Author Comment

by:dirtydinny
ID: 8079134
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
 
LVL 14

Accepted Solution

by:
avner earned 80 total points
ID: 8079164
Sure thing :
<script>document.write(new Date().toLocaleDateString())</script>

Remember that the date is printed according to the client's regional settings.
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 12133509
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

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Find out what you should include to make the best professional email signature for your organization.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question