PDA

View Full Version : Adding the date and time to web site (just text)



Danny Canada
04-04-2007, 06:55 PM
Does anyone have a simple code to add the date and time to my home page as just text (not a button and approximately a size 8 arial font)?

Thanks!!!!

*Everyone one in here offering assistance have been absolutely fabulous.

bill2006
04-04-2007, 07:11 PM
Try this, you can change the font and size:

<FONT style="font-size:13px" color="#000000" face="Comic Sans MS">
<script language="JavaScript" type="text/javascript">
<!--
var
month = new Array();
month[0]="January";
month[1]="February";
month[2]="March";
month[3]="April";
month[4]="May";
month[5]="June";
month[6]="July";
month[7]="August";
month[8]="September";
month[9]="October";
month[10]="November";
month[11]="December";
var
day = new Array();
day[0]="Sunday";
day[1]="Monday";
day[2]="Tuesday";
day[3]="Wednesday";
day[4]="Thursday";
day[5]="Friday";
day[6]="Saturday";
today = new Date();
date = today.getDate();
day = (day[today.getDay()]);
month = (month[today.getMonth()]);
year = (today.getFullYear());
suffix = (date==1 || date==21 || date==31) ? "st" : "th" &&
(date==2 || date==22) ? "nd" : "th" && (date==3 || date==23) ? "rd" : "th"
function print_date()
{
document.write(month + "&nbsp;" + date + "," + "&nbsp;" + year);
}
// -->
</script>
<script>
<!--
print_date();
//-->
</script>

davidundalicia
04-04-2007, 07:12 PM
Heres a simple script that you just add to an html box and then move the box to where ever you want on the page:

<SCRIPT>
var mydate=new Date()
var theYear=mydate.getFullYear()
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
document.write(dayarray[day]+", "+montharray[month]+" "+daym+", "+theYear)
</SCRIPT>

bill2006
04-04-2007, 07:15 PM
Just noticed that RaceFan and NavalDesigns had already provided codes.
http://www.vodahost.com/vodatalk/adding-elements-your-website/4343-how-do-i-add-todays-date-website.html

Please post your URL, www.

Danny Canada
04-04-2007, 08:49 PM
Thanks Bill2006!!

The code works great!! However, it doesn't display the day of the week. I would like to have show as: Wednesday, April 4 2007

Am I doing something wrong?

Danny

Collectors-info
04-04-2007, 09:06 PM
Hi, change this part at the bottom of the script to give the day & order you wanted.

{
document.write(day + "&nbsp;" + date + "&nbsp;" + month + "&nbsp;" + year);
}

Danny Canada
04-04-2007, 09:52 PM
Thanks Collectors-info!!

Worked like a charm... Just had to play around with positioning as well as change the text color to 'white"

Danny

bill2006
04-05-2007, 04:16 AM
Thank you Chris,
I don't show the day of the week and had deleted that part.

Danny Canada
04-05-2007, 04:26 AM
Thanks for all your help and assistance on this post as well Bill!!

You guys (and gals) are great!!

Tomissan
04-13-2007, 07:44 AM
don't know if you still need it, if you do, just copy and paste this into your html...
<iframe src="http://free.timeanddate.com/clock/iedgxdc/n28/fs15/bo2/tt0/ts1" frameborder="0" width="303" height="21"></iframe>

or, go to www.timeanddate.com and chose the format you want.

tomissan
___________________________

www.thai-land-house.com