Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Themes
Author Message
wiz
Involved
Involved



Joined: Oct 09, 2006
Posts: 413
Location: UK

PostPosted: Sat Feb 21, 2009 11:13 am Reply with quote

Hi, im trying to mod the Fisubice header. In line 151 of theme.php the variable $datetime is assigned to the javascript to calculate the date.

Currently, i have changed it to this:
Code:
$datetime = gmdate("D jS M    G:i T ");


But ideally i would like the time to be 'live' and current, so after a while digging around various sites i found this code:
Code:
<script type="text/javascript">


function live_clock()
     {
         var today  = new Date();
         var second = today.getSeconds();
         var minute = today.getMinutes();
         var hour   = today.getHours();
         var hour24 = today.getHours();
         var ampm   = "";
         
         var day    = today.getDay();
         var date   = today.getDate();
         var month  = today.getMonth();
         var year   = today.getFullYear();
         
         var days   = new Array();
          days[0]   = "Sun";
          days[1]   = "Mon";
          days[2]   = "Tues";
          days[3]   = "Wed";
          days[4]   = "Thurs";
          days[5]   = "Fri";
          days[6]   = "Sat";
         
         var mns   = new Array();
          mns[0]   = "Jan";
          mns[1]   = "Feb";
          mns[2]   = "Mar";
          mns[3]   = "Apr";
          mns[4]   = "May";
          mns[5]   = "June";
          mns[6]   = "July";
          mns[7]   = "Aug";
          mns[8]   = "Sept";
          mns[9]   = "Oct";
          mns[10]  = "Nov";
          mns[11]  = "Dec";
           
        if(second<10)
            {
                second = "0"+second;
            }
           
        if(minute<10)
            {
                minute = "0"+minute;
            }
           
        if(hour24<=12)
            {
                ampm = "AM";
            }
           
        else
            {
                ampm = "PM"
            }
           
        if(hour24>=12)
            {
                hour= hour-12;
            }
           
        if(hour24==0)
            {
                hour=12;
            }
       
        document.getElementById('live_clock').innerHTML=(hour+":"+minute+":"+second+" "+ampm+', '+date+' '+mns[month]+' '+year);
    }

</script>

<body onLoad="setInterval('live_clock()', 1000);"><div id="live_clock"></body>


But no matter how i try it, i cannot get it to work; can anyone help me.
Cheers
WIZ
 
View user's profile Send private message Visit poster's website AIM Address
spasticdonkey
RavenNuke(tm) Development Team



Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA

PostPosted: Sat Feb 21, 2009 1:37 pm Reply with quote

my guess would be the body onload statement, but I'm not JS expert. Is there another way to initiate the script?
 
View user's profile Send private message Visit poster's website
wiz







PostPosted: Sat Feb 21, 2009 1:43 pm Reply with quote

i dont know because im not a JS expert either, the gmdate function looks great for displaying GMT time, but i just would like to to update
 
spasticdonkey







PostPosted: Sat Feb 21, 2009 1:58 pm Reply with quote

your page should only have one body tag, so that code above would only have the live clock as content, since the body tag is closed afterward... just wanted to make sure you were adding that to your one-and-only body tag.

This is a similar clock that also uses body onload, but references the js as an external file, might try that.... [ Only registered users can see links on this board! Get registered or login! ]
 
wiz







PostPosted: Sat Feb 21, 2009 2:02 pm Reply with quote

Nice one..ill have a play with that after dinner Wink

Cheers
WIZ
 
wiz







PostPosted: Sat Feb 21, 2009 4:58 pm Reply with quote

I used the script that spasticdonkey listed..nice little bit of javascript there. However i followed the rule of double quoting for php etc, and all it does is echo the onload command..so again, spasticdonkey you are right, it is the onload.
Here is the current code that i have...

Code:
// Live Date and Time

datetime = "<script type='text/javascript' src='liveclock.js'></script>"."\n\n"
onLoad="show_clock()";
// End Live Date and Time


Cheers
WIZ
 
spasticdonkey







PostPosted: Sun Feb 22, 2009 1:38 am Reply with quote

I would undo the changes you did to the date and time, in case it is used elsewhere in your theme. The JS will display the time and it will read from the clients' computer so it doesn't need to be aware of the site time.

In your theme find the opening <body> tag and change to:
<body onLoad="show_clock()">

then wherever the theme displays the $datetime variable replace with the call to the external js script. Not familiar with your theme, but in fisubice it would be (themes/fisubice/header.html)
Code:
<font class="content">

$datetime
                  </font>

change to
Code:
<font class="content">

<script type="text/javascript" src="liveclock.js">

/*
Live Clock Script-
By Mark Plachetta (astro@bigpond.net.au©) based on code from DynamicDrive.com
For full source code, 100's more DHTML scripts, and Terms Of Use,
visit http://www.dynamicdrive.com
*/

</script>
                  </font>


keep in mind that particular layout is in html, and yours may be in php, also assumes that the liveclock.js is in the root directory
 
wiz







PostPosted: Sun Feb 22, 2009 8:37 am Reply with quote

My theme is Fisubice. I got sick and tired of old scripts and 'half made' themes; so i wrote this one from fisubice, change a few colours, images and classes, thats all Wink

Ive changed the $datetime var in header.html as you suggested. However i cannot find a body tag anywhere. Infact the only body i can see is a CSS class.
Am i missing something vital here?
 
spasticdonkey







PostPosted: Sun Feb 22, 2009 11:23 am Reply with quote

line 143 in fisubice/theme.php, find:
echo '<body bgcolor="#FFFFFF" text="#516A88" style="margin: 10px">';
change to:
echo '<body onLoad="show_clock()" bgcolor="#FFFFFF" text="#516A88" style="margin: 10px">';
 
wiz







PostPosted: Sun Feb 22, 2009 11:51 am Reply with quote

i can confirm that i have changed header.html and theme php as you suggest..but no cigar. liveclock.js is in my theme root folder.
 
spasticdonkey







PostPosted: Sun Feb 22, 2009 11:56 am Reply with quote

i see body onload twice in your page source
 
wiz







PostPosted: Sun Feb 22, 2009 12:12 pm Reply with quote

yep i can view this (in seamonkey). I have changed the path in header.html as you suggested..still no cigar Sad
 
spasticdonkey







PostPosted: Sun Feb 22, 2009 12:36 pm Reply with quote

hmm i got it working in fisubice, so something may be amiss. If you want to zip up your theme.php and header.html and pm me a link i'll have a look
 
wiz







PostPosted: Sun Feb 22, 2009 12:48 pm Reply with quote

Thanks a lot for taking the time, i hope this is usefull and not a waste of peoples time.
PM sent

cheers

WIZ
 
wiz







PostPosted: Sun Feb 22, 2009 1:17 pm Reply with quote

Excellent work SpasticDonkey it now displays..thankyou. I just have to change the format now..so technically...Problem Solved Smile
 
spasticdonkey







PostPosted: Sun Feb 22, 2009 1:18 pm Reply with quote

sweet Smile
there are options for the text color in the js file Smile
 
wiz







PostPosted: Sun Feb 22, 2009 1:22 pm Reply with quote

yes...but for some reason i have date only displayed..
 
spasticdonkey







PostPosted: Sun Feb 22, 2009 2:36 pm Reply with quote

the date is still pulled from theme.php, so if the time disappeared then there might be a syntax error in the js file when you edited the style. if it works only on some pages, then you might have a js conflict with another js file, which happens at times when using body onload

i see it now displayed as: 2/22/2009 test14:36:44
 
wiz







PostPosted: Sun Feb 22, 2009 2:41 pm Reply with quote

now i dont see that...in AOL, IE7 and seamonkey, i only see the date and i have used ctrl+F5, i did add the text "test" to see my changes..but i see none of it
 
spasticdonkey







PostPosted: Sun Feb 22, 2009 6:15 pm Reply with quote

It's showing for me in IE and Firefox
Image

I shortened the date since that TD is only 165px wide, you might not have room to write much in between the date and time, or there could be layout issues in some browsers
 
wiz







PostPosted: Sun Feb 22, 2009 6:37 pm Reply with quote

all i see is the date, but if you see something..then why shouldnt I?
 
spasticdonkey







PostPosted: Sun Feb 22, 2009 7:09 pm Reply with quote

not sure i have a good answer there... i'd say clear you browser cache but if it appears that way in multiple browsers, i dunno..... you could try.. Smile
 
pan
Involved
Involved



Joined: Jul 25, 2006
Posts: 354

PostPosted: Wed Mar 11, 2009 9:31 pm Reply with quote

i have read this thread over and over and cannot understand it.

i just want a clock on my site set to GMT +10 Sad
 
View user's profile Send private message
wiz







PostPosted: Wed Mar 11, 2009 10:00 pm Reply with quote

well that depends on if you want a static clock...e.g a fixed time, that only changes when the user changes or refreshes the page. If you want one that counts, you must use javascript, like i did.

The static one is easy.
Look in your themes header.tpl to see if it has the $datetime variable. If not create it wherever you want it displayed.

Then go to your theme.php and find (or create) the $datetime variable
and make sure it now reads...
$datetime = date("D jS M G:i T ");

Before this line..add this line
date_default_timezone_set('UTC'); //where UTC is your timezone.This will adjust the server time to your desired time//

you can adjust the output by changing the time constants, you can find it all here.. [ Only registered users can see links on this board! Get registered or login! ]
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Themes

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©