Topic: Current Time And Date In Footer

For Time And Date


in include/template/main.tpl

add

<body onLoad="goforit()">

before

<pun_head>

and in footer.php

add

<script>

/*
Live Date Script- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions, 100's more DHTML scripts, and Terms Of Use,
visit http://www.dynamicdrive.com
*/


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")

function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate="<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
+"</b></font></small>"
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function goforit(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}

</script>
<span id="clock"></span>

Before

<?php

// Display debug info (if enabled/defined)
if (defined('PUN_DEBUG'))

Re: Current Time And Date In Footer

Why not just use the date(); function in the footer? I guess both are good but date(); is much simpler big_smile
For the time your could use time(); then I'm 99.7% sure Rickard made a function that turns time(); to correct time formating, format_time(); or something like that, you'd have to check in functions.php.

Re: Current Time And Date In Footer

ok but this i aslo good rite

4

Re: Current Time And Date In Footer

ultime wrote:

Why not just use the date(); function in the footer? I guess both are good but date(); is much simpler big_smile
For the time your could use time();

No, of course you use date() for both.

<? echo date("Y-m-d h:i:s A") ?>

will output exactly the same as the JavaScript does.
In one single line.
I think if there is no need to use JavaScript (e.g. figure out things on the client side that the server can not know) then it is always better to use server side scripting. Faster and more reliable.

The German PunBB Site:
PunBB-forum.de

5

Re: Current Time And Date In Footer

gud 1 'mastiland'

I start thinking from where you stop thinking!!!

Re: Current Time And Date In Footer

Is the above java script a live date and time? if so thats a little better than the date function

Re: Current Time And Date In Footer

ya it shows live date and live time