Results 1 to 4 of 4

Thread: Looking for "Date & Time Script"

  1. #1
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Question Looking for "Date & Time Script"

    Hi.

    Is there a "Date & Time Script" available which can be set to not just display the current date & time but can be set to show different time zones?
    And especially show the date in languages like greek or russian for example.
    If something like this is available please link me to it.

    Thanks in advance,
    Cheng

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Do you have PHP available on your server?

    If so...
    Look into the date() and time() functions. You should very easily be able to write your own script.

    Some resources:
    http://us3.php.net/datetime
    http://us.php.net/date
    http://us.php.net/manual/en/function.time.php
    http://www.tutorialized.com/tutorial...ate-and-Time/1
    http://www.tizag.com/phpT/phpdate.php
    http://www.wdvl.com/Authoring/Languages/PHP/Date_Time/

  3. #3
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    .......thanks for your reply.
    The site I'm creating isn't on a server yet but when it's finished it shouldn't be a problem to host it on a server with PHP support.
    Anyway, I'm not that much of a coder or script writer but I'll go and have a look at the links you provided and see if I can manage to get it done.
    Thanks again.......
    Cheng

  4. #4
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    .......thanks again for the links but it was a little to complex for me or probaly I didn't understand it.

    I went for this script (see below) and I figured out how to change it to special caracters i.e. russian or greek or whatever for the weekdays and month.

    The script needed to be opened in Notepad and then saved as UTF-8 with the special caraters and then it worked.

    The time zone values are:

    System Time & Date
    PHP Code:
    function tS(){ x=new Date(); x.setTime(x.getTime()); return x; } 
    UTC
    PHP Code:
    function tS(){ x=new Date(tN().getUTCFullYear(),tN().getUTCMonth(),tN().getUTCDate(),tN().getUTCHours(),tN().getUTCMinutes(),tN().getUTCSeconds()); x.setTime(x.getTime()); return x; } 
    GMT-1
    PHP Code:
    function tS(){ x=new Date(tN().getUTCFullYear(),tN().getUTCMonth(),tN().getUTCDate(),tN().getUTCHours(),tN().getUTCMinutes(),tN().getUTCSeconds()); x.setTime(x.getTime()-3600000); return x; } 
    GMT
    PHP Code:
    function tS(){ x=new Date(tN().getUTCFullYear(),tN().getUTCMonth(),tN().getUTCDate(),tN().getUTCHours(),tN().getUTCMinutes(),tN().getUTCSeconds()); x.setTime(x.getTime()+0); return x; } 
    GMT+1
    PHP Code:
    function tS(){ x=new Date(tN().getUTCFullYear(),tN().getUTCMonth(),tN().getUTCDate(),tN().getUTCHours(),tN().getUTCMinutes(),tN().getUTCSeconds()); x.setTime(x.getTime()+3600000); return x; } 
    GMT+2
    PHP Code:
    function tS(){ x=new Date(tN().getUTCFullYear(),tN().getUTCMonth(),tN().getUTCDate(),tN().getUTCHours(),tN().getUTCMinutes(),tN().getUTCSeconds()); x.setTime(x.getTime()+7200000); return x; } 
    And so on - (3600000 intervals for each hour + or -).

    Call the script where you want it to appear with:
    PHP Code:
    <script type="text/javaScript">dT();</script> 
    Also put a link in the HTML head for the js file:
    PHP Code:
    <script type="text/javaScript" src="date_time_script.js"></script> 
    PHP Code:
    function tS(){ x=new Date(tN().getUTCFullYear(),tN().getUTCMonth(),tN().getUTCDate(),tN().getUTCHours(),tN().getUTCMinutes(),tN().getUTCSeconds()); x.setTime(x.getTime()+10800000); return x; } 
    function 
    tN(){ return new Date(); } 
    function 
    lZ(x){ return (x>9)?x:'0'+x; } 
    function 
    dE(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 
    dT(){ if(fr==0){ fr=1document.write('<font size=2 font color=#000000 face=Verdana><b><span id="tP">'+eval(oT)+'</span></b></font>'); } document.getElementById('tP').innerHTML=eval(oT); setTimeout('dT()',1000); } 
    function 
    y4(x){ return (x<500)?x+1900:x; } 
    var 
    dN=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'),mN=new Array('January','February','March','April','May','June','July','August','September','October','November','December'),fr=0,oT="dN[tS().getDay()]+','+' '+mN[tS().getMonth()]+' '+tS().getDate()+dE(tS().getDate())+' '+y4(tS().getYear())+' '+'-'+' '+lZ(tS().getHours())+':'+lZ(tS().getMinutes())+':'+lZ(tS().getSeconds())+' '"
    No PHP server required and maybe some of you guys have use for this script as well.

    P.S
    What I didn't figure out yet is how to change the font size into px values.

    Cheers.......
    Cheng

Bookmarks

Posting Permissions

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