Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Aug 2003
    Location
    Virginia, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help with dynamic clock script - remove the date but leave the time

    Can someone help modify this? I want only the time (with the seconds) to display. Not the date. Also, how can I make the time bold? Thanks

    <script language="JavaScript">
    function tS(){ x=new Date(tN().getUTCFullYear(),tN().getUTCMonth(),tN().getUTCDate(),tN().getUTCHours(),tN().getUTCMinute s(),tN().getUTCSeconds()); x.setTime(x.getTime()+dS()-21600000); return x; }
    function tN(){ return new Date(); }
    function dS(){ return ((tN().getTime()>fD(0,3,1,1).getTime())&&(tN().getTime()<fD(0,9,1,-1).getTime()))?3600000:0; }
    function fD(d,m,h,p){ var week=(p<0)?7*(p+1):7*(p-1),nm=(p<0)?m+1:m,x=new Date(tN().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 lZ(x){ return (x>9)?x:'0'+x; }
    function tH(x){ if(x==0){ x=12; } return (x>12)?x-=12:x; }
    function y2(x){ x=(x<500)?x+1900:x; return String(x).substring(2,4) }
    function dT(){ if(fr==0){ fr=1; document.write('<span id="tP">'+eval(oT)+'</span>'); } tP.innerText=eval(oT); setTimeout('dT()',1000); }
    function aP(x){ return (x>11)?'pm':'am'; }
    var dN=new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'),fr=0,oT="dN[tS().getDay()]+' '+tS().getDate()+'-'+(tS().getMonth()+1)+'-'+y2(tS().getYear())+' '+':'+':'+' '+tH(tS().getHours())+':'+lZ(tS().getMinutes())+':'+lZ(tS().getSeconds())+' '+aP(tS().getHours())";
    </script>

    -----

    <script language="JavaScript">dT();</script>

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    modify (get rid of you don't need) here:

    Code:
    oT="dN[tS().getDay()]+' '+tS().getDate()+'-'+(tS().getMonth()+1)+'-'+y2(tS().getYear())+' '+':'+':'+' '+tH(tS().getHours())+':'+lZ(tS().getMinutes())+':'+lZ(tS().getSeconds())+' '+aP(tS().getHours())";
    insert <strong></strong> tags here:
    Code:
    document.write('<span id="tP">'+eval(oT)+'</span>');
    I assumed that you know enough javascript to do it by yourself
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Registered User
    Join Date
    Aug 2003
    Location
    Virginia, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I know enough to get me in trouble.

    I've modified it to this and it seems to be working fine.

    <script language="JavaScript">
    function tS(){ x=new Date(tN().getUTCFullYear(),tN().getUTCMonth(),tN().getUTCDate(),tN().getUTCHours(),tN().getUTCMinute s(),tN().getUTCSeconds()); x.setTime(x.getTime()+dS()-21600000); return x; }
    function tN(){ return new Date(); }
    function dS(){ return ((tN().getTime()>fD(0,3,1,1).getTime())&&(tN().getTime()<fD(0,9,1,-1).getTime()))?3600000:0; }
    function fD(d,m,h,p){ var week=(p<0)?7*(p+1):7*(p-1),nm=(p<0)?m+1:m,x=new Date(tN().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 lZ(x){ return (x>9)?x:'0'+x; }
    function tH(x){ if(x==0){ x=12; } return (x>12)?x-=12:x; }
    function y2(x){ x=(x<500)?x+1900:x; return String(x).substring(2,4) }
    function dT(){ if(fr==0){ fr=1; document.write('<b><span id="tP">'+eval(oT)+'</span></b>'); } tP.innerText=eval(oT); setTimeout('dT()',1000); }
    function aP(x){ return (x>11)?'pm':'am'; }
    var dN=new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'),fr=0,oT="''+tH(tS().getHours())+':'+lZ(tS().getMinu tes())+':'+lZ(tS().getSeconds())+' '+aP(tS().getHours())";
    </script>

    Erika

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    there remainded some redundant code lines, but if it works fine, and you don't to make a contest art designe code leave it as it is, and save your time. Good luck, now
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •