p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript How-To (http://p2p.wrox.com/forumdisplay.php?f=87)
-   -   javascript to write out two different time zones (http://p2p.wrox.com/showthread.php?t=42954)

crmpicco May 24th, 2006 08:02 AM

javascript to write out two different time zones
I am looking for a javascript (if possible) that will display two times from two different time zones at the foot of a page.

Like this:

TWL® NA Time: 5/24/2006 9:01:57 AM
TWL® EU Time: 5/24/2006 3:01:57 PM

If you take a look at this website, and scroll down to the bottom
http://www.teamwarfare.com/ you will se what I mean.

Can that be done with JavaScript, or is that more SS stuff? PHP or ASP maybe?

Any help appreciated.



Dj Kat May 25th, 2006 10:18 AM


Maybe this awnser is not what your looking for but why don't you calculate the 2e time from one time and display 2 different times

__________________________________________________ ________
This is my junk I'm gona eat it

crmpicco May 25th, 2006 10:55 AM

thanks DJ Kat, this is my working script:


// Last Edit: CRM_25may06
Clock for Paris, FR and New York, US to be displayed at the foot of all pages
Genuine code by Corneliu Lucian "KOR" Rusu mailto:corneliulucian(AROND)apropo.ro
var wd=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
var D=[
['EU (Paris) Time:',60,60],//city,standard time zone(minutes), DST(minutes)
['NA (New York) Time:',-300,60] // Six Hours behind GMT
function calc()
    var spans=document.getElementById('zonediv').getElementsByTagName('span');
    for(var i=0;i<D.length;i++)
        var t=new Date();
        t.setTime(t.getTime()+(t.getTimezoneOffset()*60000)+((D[i][1]+D[i][2])*60000));//the zone's time
        var Dy=t.getFullYear();
        var Dd=t.getDate()<10?'0'+t.getDate():t.getDate();
        var Dm=t.getMonth()<10?'0'+(t.getMonth()+1):t.getMonth()+1;
        var Dh=t.getHours()<10?'0'+t.getHours():t.getHours();
        var Di=t.getMinutes()<10?'0'+t.getMinutes():t.getMinutes();
        var Ds=t.getSeconds()<10?'0'+t.getSeconds():t.getSeconds();
        var Dz=wd[t.getDay()];
        spans[i].firstChild.data=Dh+':'+Di+':'+Ds+' - '+Dz+' '+Dd+'/'+Dm+'/'+Dy;
    var root = document.getElementById('zonediv');
    for(var i=0;i<D.length;i++)
        root.appendChild(document.createTextNode(D[i][0]+' '));
        var sp=document.createElement('span');
        sp.appendChild(document.createTextNode(' '));


All times are GMT -4. The time now is 02:09 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.