Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Time script not working after edit

Time script not working after edit
Thread Tools
Senior User
Join Date: Jul 2004
Status: Offline
Reply With Quote
May 17, 2005, 09:45 AM
 
I found a cool time script that uses GMT time instead of the cpu time.
got this for my webpage im making for someones bussiness

Heres the script thats supposed to change the time when just changing the variable

Code:
var Time_offset=T2 function MyTime_offset(){ if Time_offset==T1 {T1=54000000} if Time_offset==T2 {T2=61200000}

Heres whats doing the time chaning

Code:
//Edit the Time here function daylightSaving(){ return ((timeNow().getTime()>findDay(0,3,1,1).getTime())&&(timeNow().getTime()<findDay(0,9,1,-1).getTime()))?+MyTime_offset:0; }



Heres my full script. Some var commands were // out because i am functioning them to do other stuff more easy.

Code:
////////////////////////////////////////////////////////////////////// //////////////CUSTOMIZATION/////////////////////////////////////////// var MyhtmlStart = "<table><tr><td width=50%><hr size='5' id='HRRULE'> Todays Date:" var Myhtmlend = "<hr size='5' id='HRRULE'></td><td widht=50%></td></tr></table>" var Mytime_PM = "PM" var Mytime_AM = "AM" var MyTime_leadzero = "0" //Time off set will change the time by 3600000 //Time off set for Eastern Time is: 72000000 //Time off set for Central time is 68400000 //Time off set for Mountain Time is: 64800000 //Time off set for Pacific Time is: 61200000 //Time off set for Hawaii Time is: 54000000 //var MyTime_offset = "54000000" var Time_offset=T2 function MyTime_offset(){ if Time_offset==T1 {T1=54000000} if Time_offset==T2 {T2=61200000} ///////////////END OF CUSTOMIZATION/////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ///////DONT EDIT BELOW THIS LINE OR IT HAS THE CHANCE OF NOT WORKING// /////////////////////I MEAN IT//////////////////////////////////////// function timeSource(){ x=new Date(timeNow().getUTCFullYear(),timeNow().getUTCMonth(),timeNow().getUTCDate(),timeNow().getUTCHours(),timeNow().getUTCMinutes(),timeNow().getUTCSeconds()); x.setTime(x.getTime()+daylightSaving()+0); return x; } function timeNow(){ return new Date(); } //Edit the Time here function daylightSaving(){ return ((timeNow().getTime()>findDay(0,3,1,1).getTime())&&(timeNow().getTime()<findDay(0,9,1,-1).getTime()))?+MyTime_offset:0; } function findDay(d,m,h,p){ var week=(p<0)?7*(p+1):7*(p-1),nm=(p<0)?m+1:m,x=new Date(timeNow().getUTCFullYear(),nm,1,h,0,0),dOff=0; if(p<0){ x.setTime(x.getTime()-86400000); } if(x.getDay()!=d){ dOff=(x.getDay()<d)?(d-x.getDay()):0-(x.getDay()-d); if(p<0&&dOff>0){ week-=7; } if(p>0&&dOff<0){ week+=7; } x.setTime(x.getTime()+((dOff+week)*86400000)); } return x; } function leadingZero(x){ return (x>9)?x: MyTime_leadzero+x; } function twelveHour(x){ if(x==0){ x=12; } return (x>12)?x-=12:x; } function dateEnding(x){ if(x==1||x==21||x==31){ return 'st'; } if(x==2||x==22){ return 'nd'; } if(x==3||x==23){ return 'rd'; } return 'th'; } function displayTime(){ if(fr==0){ fr=1; document.write(MyhtmlStart+' '+' <span id="tP">'+eval(outputTime)+'</span>'+' '+Myhtmlend); } tP.innerText=eval(outputTime); setTimeout('displayTime()',1000); } function amPMsymbol(x){ return (x>11)?Mytime_PM:Mytime_AM; } function fixYear4(x){ return (x<500)?x+1900:x; } var monthNames=new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); var fr=0; var outputTime="twelveHour(timeSource().getHours())+':'+leadingZero(timeSource().getMinutes())+':'+leadingZero(timeSource().getSeconds())+' '+amPMsymbol(timeSource().getHours())+' '+'of'+' '+monthNames[timeSource().getMonth()]+' '+timeSource().getDate()+dateEnding(timeSource().getDate())+' '+fixYear4(timeSource().getYear())";
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:32 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2