Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Timezone Math

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #36823
    schart
    Participant

    So members register a timezone from a HTML select list (values -5, +6.5 and so on), and I am going to do a simple +/- in the timestamp on the page where it is.
    Basically, this is what I came up with (with help from Google, my dear friend):


    $timeone = "+10";
    $timetwo = "-4";
    $number = "18:00";

    $exchange = substr($timetwo, 0, 1);
    $therest = substr($timetwo, 1);

    $result = $number. " " .$exchange. " " .$therest;
    $add_em = explode("+", $result);
    $add_em = explode("-", $result);
    echo array_sum($add_em);
    ?>

    Timeone works, but not timetwo. Could anyone try to help me?

    #97423
    karlpcrowley
    Participant

    Your code doesn’t know it’s a time
    I don’t have access to run PHP at the moment but try this:


    //3600 = 1 hour
    $time = 18*3600; // 18 for 6PM


    $a = $time + 36000; // +10 hours
    $b = $time - 14400; // -4 Hours

    echo "+10 hours: ";
    print date("G:i",$a);

    echo " -4 hours: ";
    print date("G:i",$b);

    ?>
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.