Mike35
10-13-2003, 05:37 PM
Hello,I was wondering if anyone could tell me a code that would display the current date/time. I don't know if this is possible in HTML and I'm new to website building so any help would be appreciated.
mike
mike
|
Click to See Complete Forum and Search --> : Day time date. Mike35 10-13-2003, 05:37 PM Hello,I was wondering if anyone could tell me a code that would display the current date/time. I don't know if this is possible in HTML and I'm new to website building so any help would be appreciated. mike PeOfEo 10-13-2003, 05:51 PM It can be done with a simple java script <b>Todays Date: </b><SCRIPT LANGUAGE="JavaScript" type="text/javascript"> <!-- Stamp = new Date(); document.write('' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+Stamp.getYear() + ' <br> '); var Hours; var Mins; var Time; Hours = Stamp.getHours(); if (Hours >= 12) { Time = " P.M."; } else { Time = " A.M."; } if (Hours > 12) { Hours -= 12; } if (Hours == 0) { Hours = 12; } Mins = Stamp.getMinutes(); if (Mins < 10) { Mins = "0" + Mins; } document.write('<B>Todays Time:</b> ' + Hours + ":" + Mins + Time + ''); //--> </SCRIPT> It only took me a second to find this on google... pyro 10-13-2003, 07:10 PM It should, however, use getFullYear(), as getYear() will return 103... ;) Charles 10-13-2003, 07:54 PM You can really shorten that, and make it more user friendly, by using... <script type="text/javascript"> <!-- document.write('<p>', new Date().toLocaleString(), '</p>'); // --> </script> PeOfEo 10-13-2003, 07:57 PM Heh I did not write it I just wanted to find it on google so I could say to people this only took my 2.3 minuits to find on google, lol. I would rather people find snippets themselves instead of having one of us write them a script or dig it up when it is a simple thing like this and it is not something like how would I go about doing this or do you have an idea or suggestion type of question. pyro 10-13-2003, 08:02 PM You could just post this link: http://www.google.com/search?q=learn+to+search+google :D PeOfEo 10-13-2003, 09:23 PM HAHA that is a good one! I will need to use that sometime. Mike35 10-14-2003, 12:17 PM Well actually I did search google,but I typed I was searching for the HTML code that did that. Sorry for the noob post ,but there's no need to flame me. Anyway, I have a question. HOw could I take that code and have it update the minute when the time changes other than the whole page refreshing. thanks for your help. mike Charles 10-14-2003, 12:34 PM <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="Content-Script-Type" content="text/javascript"> <title>Example</title> <script type="text/javascript"> <!-- if (document.getElementById) onload = function () {setInterval("document.getElementById('date-time').firstChild.data = new Date().toLocaleString()", 250)} document.write('<p>It is now <span id="date-time">', new Date().toLocaleString(), '</span></p>'); // --> </script> PeOfEo 10-14-2003, 05:36 PM Originally posted by Mike35 but there's no need to flame me We were not flaming you. But I like to point it out when something is easy to find. If I were flaming you I would use some of my really good insult pics (most are too dirty and mean for this forum) and since the image code on this forum is disabled I would use a link to them :) ... I don't flame people on this forum. Mike35 10-15-2003, 01:23 PM <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="Content-Script-Type" content="text/javascript"> <title>Example</title> <script type="text/javascript"> <!-- if (document.getElementById) onload = function () {setInterval("document.getElementById('date-time').firstChild.data = new Date().toLocaleString()", 250)} document.write('<p>It is now <span id="date-time">', new Date().toLocaleString(), '</span></p>'); // --> </script> Ahh charles your a life saver. mike webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |