This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > August 2004 > Real time date insertion





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Real time date insertion
Phil Handforth

2004-08-10, 12:14 pm

I'm somewhat of a rookie, please forgive, but does anyone know how I can
insert time 'real-time' as someone visits a web site? I presume there is an
extension available?

regards
Phil


~Flash~

2004-08-10, 12:14 pm

I havn't seen an extention for this yet you can use this javascript below for
real time and date (it connects to the users system clock) but it's a large
file so you may want to use an external javascript file.

Flash

<script language="javascript">

// Javascrpt Date

var dayName = new Array ("Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday")
var monName = new Array ("January", "February", "March", "April", "May",
"June", "July", "August", "September", "October", "November", "December")
var now = new Date
var today = new Date()
var year = today.getYear()
if(year<1000) year+=1900
document.write(dayName[now.getDay()] + ", " + monName[now.getMonth()] + "
"+now.getDate() +", "+year)
</script>

<script language="javascript">

// Javascrpt Clock

// Change to the font style you want your clocks text in
var myfont_face = "Arial";
// Change to the size you want your font in
var myfont_size = "9";
// Change to the color you want your font in
var myfont_color = "#ffffff";
// Change to the background color of your site
var myback_color = "#3C1313";
// don't edit past here
var mywidth = 80;
var my12_hour = 1;
var dn = ""; var old = "";
if (document.all||document.getElementById) { document.write('<span
id="LiveClockIE" style="width:'+mywidth+'px;
background-color:'+myback_color+'"></span>'); }
else if (document.layers) { document.write('<ilayer bgColor="'+myback_color+'"
id="ClockPosNS"><layer width="'+mywidth+'"
id="LiveClockNS"></layer></ilayer>'); }
else { old = "true"; show_clock(); }
function show_clock() {
if (document.layers)
document.ClockPosNS.visibility="show"
if (old == "die") { return; }
var Digital = new Date();
var hours = Digital.getHours();
var minutes = Digital.getMinutes();
var seconds = Digital.getSeconds();
if (my12_hour) {
dn = "AM";
if (hours > 12) { dn = "PM"; hours = hours - 12; }
if (hours == 0) { hours = 12; }
} else {
dn = "";
}
if (minutes <= 9) { minutes = "0"+minutes; }
if (seconds <= 9) { seconds = "0"+seconds; }
myclock = '';
myclock += '<font style="color:'+myfont_color+'; font-family:'+myfont_face+';
font-size:'+myfont_size+'pt;">';
myclock += hours+':'+minutes+':'+seconds+' '+dn;
myclock += '</font>';
if (old == "true") {
document.write(myclock);
old = "die"; return;
}
if (document.layers) {
clockpos = document.ClockPosNS;
liveclock = clockpos.document.LiveClockNS;
liveclock.document.write(myclock);
liveclock.document.close();
} else if (document.all) {
LiveClockIE.innerHTML = myclock;
} else if (document.getElementById) {
document.getElementById("LiveClockIE").innerHTML = myclock;
}
setTimeout("show_clock()",1000);
}
</script>

~Flash~

2004-08-10, 12:14 pm

Notice there's two scripts there the top one is the Date and the bottom is the clock the clock needs for you to change the font color, size, background color?

Flash
htown

2004-08-10, 11:18 pm

If your hosting company servers can read ASP pages you can use the code:
<% Response.Write ("Current time is: " & Time())%>
within your HTML pages as is. But the extion to the file name must end in .asp.

index.html will not work index.asp will work provided that your hosting
company supports the use of ASP.

htown

2004-08-10, 11:18 pm

If your hosting company servers can read ASP pages you can use the code:
<% Response.Write ("Current time is: " & Time())%>
within your HTML pages as is. But the extion to the file name must end in .asp.

index.html will not work index.asp will work provided that your hosting
company supports the use of ASP.

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews