Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Time zones

Hi,

I have to print on one page time on 3 different time-zone:

Bahamas (GMT - 5) - Liechtenstein (GMT + 1) - Cyprus (GMT + 2)

It can be solved by JavaScript or PHP. Somebody has solution? To get GMT time and calculate relative times or ...?

Thanks.

Comments

  • ljubaljuba Posts: 106Member
    Hello,

    Because it was urgent I solved it by PHP like this:

    <?php
    // Bahamas (GMT - 5) - Liechtenstein (GMT + 1) - Cyprus (GMT + 2)
    echo "<b>Bahamas ".date("(H:i)", mktime(gmdate("H")-5,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))." - ";
    echo "Liechtenstein ".date("(H:i)", mktime(gmdate("H")+1,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))." - ";
    echo "Cyprus ".date("(H:i)", mktime(gmdate("H")+2,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))." ";
    ?>

    global:

    <?php
    echo "Times:<br>
    ";
    echo "Grinich - 7: ".date("M, d Y (H:i:s)", mktime(gmdate("H")-7,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    echo "Grinich - 6: ".date("M, d Y (H:i:s)", mktime(gmdate("H")-6,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    echo "Grinich - 5: ".date("M, d Y (H:i:s)", mktime(gmdate("H")-5,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    echo "Grinich - 4: ".date("M, d Y (H:i:s)", mktime(gmdate("H")-4,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    echo "Grinich - 3: ".date("M, d Y (H:i:s)", mktime(gmdate("H")-3,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    echo "Grinich - 2: ".date("M, d Y (H:i:s)", mktime(gmdate("H")-2,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    echo "Grinich - 1: ".date("M, d Y (H:i:s)", mktime(gmdate("H")-1,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    echo "Grinich + 0: ".date("M, d Y (H:i:s)", mktime(gmdate("H")+0,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    echo "Grinich + 1: ".date("M, d Y (H:i:s)", mktime(gmdate("H")+1,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    echo "Grinich + 2: ".date("M, d Y (H:i:s)", mktime(gmdate("H")+2,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    echo "Grinich + 3: ".date("M, d Y (H:i:s)", mktime(gmdate("H")+3,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    echo "Grinich + 4: ".date("M, d Y (H:i:s)", mktime(gmdate("H")+4,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    echo "Grinich + 5: ".date("M, d Y (H:i:s)", mktime(gmdate("H")+5,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    echo "Grinich + 6: ".date("M, d Y (H:i:s)", mktime(gmdate("H")+6,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    echo "Grinich + 7: ".date("M, d Y (H:i:s)", mktime(gmdate("H")+7,gmdate("i"),gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y")))."

    ";
    ?>

    Regards

    LJUBA
Sign In or Register to comment.