+ Reply to Thread
Results 1 to 10 of 10

Thread: date and time

  1. #1
    cuteboytm is offline x10Hosting Member cuteboytm is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    7

    date and time

    Code:
       <script language=Javascript1.2>
    <!--
    
    var tags_before_clock = "<b>It is now "
    var tags_middle_clock = "on"
    var tags_after_clock  = "</b>"
    
    if(navigator.appName == "Netscape") {
    document.write('<layer id="clock"></layer><br>');
    }
    
    if (navigator.appVersion.indexOf("MSIE") != -1){
    document.write('<span id="clock"></span>');
    }
    
    DaysofWeek = new Array()
      DaysofWeek[0]="Sunday"
      DaysofWeek[1]="Monday"
      DaysofWeek[2]="Tuesday"
      DaysofWeek[3]="Wednesday"
      DaysofWeek[4]="Thursday"
      DaysofWeek[5]="Friday"
      DaysofWeek[6]="Saturday"
    
    Months = new Array()
      Months[0]="January"
      Months[1]="February"
      Months[2]="March"
      Months[3]="April"
      Months[4]="May"
      Months[5]="June"
      Months[6]="July"
      Months[7]="August"
      Months[8]="September"
      Months[9]="October"
      Months[10]="November"
      Months[11]="December"
    
    function upclock(){
    var dte = new Date();
    var hrs = dte.getHours();
    var min = dte.getMinutes();
    var sec = dte.getSeconds();
    var day = DaysofWeek[dte.getDay()]
    var date = dte.getDate()
    var month = Months[dte.getMonth()]
    var year = dte.getFullYear()
    
    var col = ":";
    var spc = " ";
    var com = ",";
    var apm;
    
    if (date == 1 || date == 21 || date == 31)
      {ender = "<sup>st</sup>"}
    else
    if (date == 2 || date == 22)
      {ender = "<sup>nd</sup>"}
    else
    if (date == 3 || date == 23)
      {ender = "<sup>rd</sup>"}
    
    else
      {ender = "<sup>th</sup>"}
    
    if (12 < hrs) {
    apm="<font size='-1'>pm</font>";
    hrs-=12;
    }
    
    else {
    apm="<font size='-1'>am</font>";
    }
    
    if (hrs == 0) hrs=12;
    if (hrs<=9) hrs="0"+hrs;
    if (min<=9) min="0"+min;
    if (sec<=9) sec="0"+sec;
    
    if(navigator.appName == "Netscape") {
    document.clock.document.write(tags_before_clock+hrs+col+min+col+sec+apm+spc+tags_middle_clock+spc+day+com+spc+date+ender+spc+month+com+spc+year+tags_after_clock);
    document.clock.document.close();
    }
    
    if (navigator.appVersion.indexOf("MSIE") != -1){
    clock.innerHTML = tags_before_clock+hrs+col+min+col+sec+apm+spc+tags_middle_clock+spc+day+com+spc+date+ender+spc+month+com+spc+year+tags_after_clock;
    }
    }
    
    setInterval("upclock()",1000);
    //-->
    </script>

  2. #2
    DarkDragonLord's Avatar
    DarkDragonLord is offline x10 Elder DarkDragonLord is an unknown quantity at this point
    Join Date
    Mar 2007
    Location
    Brazil
    Posts
    782

    Re: date and time

    Works with Mozilla Firefox?
    Regards,
    Raphael DDL

    Designing Solutions for You
    *Web Design;
    *Coding;
    Free Downloads;
    and all related Stuff
    .


    My Tutorials:
    | Multi-Language Websites | Rotative Banners |
    | Bookmark Script for All Browsers
    |
    |
    PHP Switching/Including Content|
    |


  3. #3
    eminemix's Avatar
    eminemix is offline x10 Lieutenant eminemix is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    EU
    Posts
    349

    Re: date and time

    You could try a php alternative too :
    <?php
    // Assuming today is: March 10th, 2001, 5:16:18 pm

    $today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
    $today = date("m.d.y"); // 03.10.01
    $today = date("j, n, Y"); // 10, 3, 2001
    $today = date("Ymd"); // 20010310
    $today = date('h-i-s, j-m-y, it is w Day z '); // 05-16-17, 10-03-01, 1631 1618 6 Fripm01
    $today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // It is the 10th day.
    $today = date("D M j G:i:s T Y"); // Sat Mar 10 15:16:08 MST 2001
    $today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:17 m is month
    $today = date("H:i:s"); // 17:16:17
    ?>


  4. #4
    lambada's Avatar
    lambada is offline x10 Elder lambada is an unknown quantity at this point
    Join Date
    Mar 2006
    Location
    Caister, Gt Yarmouth, Norfolk, ENGLAND
    Posts
    1,222

    Re: date and time

    But the PHP one relies on the server time. Which may well be different from the users time because of timezones etc.
    Lambada - the former Account Manager (before I resigned)




  5. #5
    Join Date
    Aug 2007
    Location
    Gangstas Paradise
    Posts
    4,143

    Re: date and time

    Talking of date and time. When I try and get a GMT time from the server it appears to be an hour behind what I would assume to be the GMT time.

    http://dev.x10hosting.com (this has nothing to do with x10hosting)

    ->All us helpful people here at x10hosting would like to reach our next user groups, "Community Paragon". Please click the +rep icon on the left hand side of a post if that post was helpfull.



  6. #6
    Sohail's Avatar
    Sohail is offline x10 Spammer Sohail is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    London, UK
    Posts
    3,052

    Re: date and time

    Thanks for the script! :D I'd rather use PHP since it's more reliable...

  7. #7
    mattura's Avatar
    mattura is offline x10 Elder mattura is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    563

    Re: date and time

    I discovered how to change the timezone in php, see this post:
    http://forums.x10hosting.com/site-ma...-timezone.html
    ----
    Life is a game. The conception is terrible but the graphics are amazing!
    matt.elementfx.com

  8. #8
    lambada's Avatar
    lambada is offline x10 Elder lambada is an unknown quantity at this point
    Join Date
    Mar 2006
    Location
    Caister, Gt Yarmouth, Norfolk, ENGLAND
    Posts
    1,222

    Re: date and time

    Quote Originally Posted by DefecTalisman View Post
    Talking of date and time. When I try and get a GMT time from the server it appears to be an hour behind what I would assume to be the GMT time.
    Don't forget to allow for Daylight Savings Time which may account for this 'error' you're seeing.
    Lambada - the former Account Manager (before I resigned)




  9. #9
    Join Date
    Aug 2007
    Location
    Gangstas Paradise
    Posts
    4,143

    Re: date and time

    That would make sense. But we dont have daylight savings in my country. Humor me on this, when daylight savings is active does this mean that GMT is actually GMT+1?

    http://dev.x10hosting.com (this has nothing to do with x10hosting)

    ->All us helpful people here at x10hosting would like to reach our next user groups, "Community Paragon". Please click the +rep icon on the left hand side of a post if that post was helpfull.



  10. #10
    Sundowner's Avatar
    Sundowner is offline x10Hosting Member Sundowner is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    Diss, Norfolk, UK
    Posts
    27

    Re: date and time

    No, GMT is constant

+ Reply to Thread

Similar Threads

  1. Replies: 4
    Last Post: 01-05-2006, 10:27 AM
  2. Replies: 4
    Last Post: 09-04-2005, 03:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers