PHP Web Host - Quality Web Hosting For All PHP Applications Sign up for PayPal and start accepting credit card payments instantly
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
wiz
Client


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

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

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: 1364
Location: Texas, USA

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

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
wiz
Client


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

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

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
View user's profile Send private message Visit poster's website AIM Address
spasticdonkey
RavenNuke(tm) Development Team


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

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

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 to the forums!
View user's profile Send private message
wiz
Client


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

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

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

Cheers
WIZ
View user's profile Send private message Visit poster's website AIM Address
wiz
Client


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

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

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
View user's profile Send private message Visit poster's website AIM Address
spasticdonkey
RavenNuke(tm) Development Team


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

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

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
View user's profile Send private message
wiz
Client


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

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

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?
View user's profile Send private message Visit poster's website AIM Address
spasticdonkey
RavenNuke(tm) Development Team


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

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

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">';
View user's profile Send private message
wiz
Client


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

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

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.
View user's profile Send private message Visit poster's website AIM Address
spasticdonkey
RavenNuke(tm) Development Team


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

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

i see body onload twice in your page source
View user's profile Send private message
wiz
Client


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

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

yep i can view this (in seamonkey). I have changed the path in header.html as you suggested..still no cigar Sad
View user's profile Send private message Visit poster's website AIM Address
spasticdonkey
RavenNuke(tm) Development Team


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

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

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
View user's profile Send private message
wiz
Client


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

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

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

cheers

WIZ
View user's profile Send private message Visit poster's website AIM Address
wiz
Client


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

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

Excellent work SpasticDonkey it now displays..thankyou. I just have to change the format now..so technically...Problem Solved Smile
View user's profile Send private message Visit poster's website AIM Address
spasticdonkey
RavenNuke(tm) Development Team


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

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

sweet Smile
there are options for the text color in the js file Smile
View user's profile Send private message
wiz
Client


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

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

yes...but for some reason i have date only displayed..
View user's profile Send private message Visit poster's website AIM Address
spasticdonkey
RavenNuke(tm) Development Team


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

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

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
View user's profile Send private message
wiz
Client


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

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

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
View user's profile Send private message Visit poster's website AIM Address
spasticdonkey
RavenNuke(tm) Development Team


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

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

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
View user's profile Send private message
wiz
Client


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

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

all i see is the date, but if you see something..then why shouldnt I?
View user's profile Send private message Visit poster's website AIM Address
spasticdonkey
RavenNuke(tm) Development Team


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

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

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
View user's profile Send private message
pan
Involved
Involved


Joined: Jul 25, 2006
Posts: 354

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

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
Client


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

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

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 to the forums!
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:       
Post new topic   Reply to topic

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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum