Forums

This topic is locked

Insert Date into webpage

Posted 23 Mar 2006 00:08:40
1
has voted
23 Mar 2006 00:08:40 Paul Mowery posted:
I found some code which is supposed to allow me to keep the date on my webpage and automatically update it when the page loads. I have tried going into code mode and pasting the code but it just comes out blank once it is published.

Here is the code I was using.

<script language="javascript">

function dodate() {
var dateis = new date;
var dayofweek = dateis.getDay();
var dayofmonth = dateis.getdate();
var x = new Array("Sunday,", "Monday,", "Tuesday,", "Wednesday,","Thursday,", "Friday,", "Saturday,";
var interrim;

if (dayofmonth == 1 ¦¦ dayofmonth == 21 ¦¦ dayofmonth == 31) {
interrim = "st";
}
else {
if (dayofmonth == 2 ¦¦ dayofmonth == 22) {
interrim = "nd";
}
else {
if (dayofmonth == 3 ¦¦ dayofmonth == 23) {
interrim = "rd";
}
else {
interrim = "th";
}
}
}

interrim = x[dayofweek] + " " + dayofmonth + interrim;
x = new Array("of January", "of February", "of March", "of April", "of May", "of June", "of July", "of August", "of September", "of October", "of November", "of December";
interrim = interrim + " " + x[dateis.getMonth()] +", ";
x = dateis.getYear();
if (x < 1999) { x += 1900; } return interrim + x;
}

window.document.write(dodate());

</script>

Thank you for any help you can provide.

Replies

Replied 09 Oct 2009 00:33:51
09 Oct 2009 00:33:51 Peter Pritchard replied:
If your page has .php ext, just use<?php echo date("l F d, Y";?>

Peter
Replied 10 Oct 2009 16:15:53
10 Oct 2009 16:15:53 Patrick Julicher replied:
Hi Peter/Paul,

There are numerous options to update todays date on a page. Google is your friend to finding various examples.

Kind regards, Patrick

Reply to this topic