SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript to Display Two Concurrent Time Zones

    I have a free script working that I modified (nothing major -- I really just use them, not create them) to use in a HTML table cell such as-

    Nov 8, 2001
    4:45 PM

    The original script was customized to display "Good Morning," "Good Afternoon," or "Good Evening." The "Good Morning" case is-
    //Get the current hours
    hourvalue = d.getHours();
    //customize the greeting based on the current hours
    if (hourValue < 12)
    {
    greeting = "Good Morning!"
    timeText = hourValue + ":" + minuteValue + " AM"
    }
    ...for 12, 17...

    I would like to change
    greeting = "Good Morning!" TO
    greeting = "Hawaii"
    and modify the parameters so that I have a 5-hour offset between my Baltimore EST clock and the Hawaii HST clock as the following example:

    Baltimore
    Nov 8, 2001
    4:00 PM

    Hawaii
    Nov 8, 2001
    11:00 AM

    I would like to add EST and HST suffixes also.

    Can anyone examine what I have here and make appropiate changes to display the two time zones shown just above. I can send more of the code I am using if required.

    Thanks,
    Ken Baker

  2. #2
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe you can use the following statement:

    hourvalue-=5

    or create a new variable

    HIhourvalue = hourvalue-5

  3. #3
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Time Zone Offset

    Hi, er, Moospot,

    I will try to insert your suggestion. (But I am not very good with JavaScript.)

    Thanks for your post. I guess it was too long for most people to bother with. I'll try to keep them shorter in the future.

    Ken Baker

  4. #4
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think it was too long. Most people do not put enough information in their posts.

  5. #5
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Two Concurrent Time Zones

    I've run into a problem according to another forum because my code, running in a USER's computer in another time zone, may not produce the results I want, or worse. I'm trying to understand it.

    Ken

  6. #6
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe you could start off by getting the greenwich mean time (gmt) and basing your calculations off of that?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  7. #7
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ken,

    You should use a server-side script. Is your server ASP enabled? You can easily show the time of the server, which is probably what you want to do, right?


    Here's the code:

    Code:
    <%= time() %>
    Start a new thread in the ASP forums for all the details on displaying dates and times in ASP
    Last edited by moospot; Nov 12, 2001 at 17:20.


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
  •