Web Analytics Made Easy -
StatCounter time difference error - CodingForum

Announcement

Collapse
No announcement yet.

time difference error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • time difference error

    http://melody.freeprohost.com/guest.php
    I would like to use the above PHP guestbook (created by someone for free downloading). I like it because it allows one to redesign in accordance to one's liking and also set the time difference accordingly.

    But i have a problem here. The server from USA that I use has a time difference of 5 hours from the guestbook setting that I use.
    I modify the time difference setting but the time during which any message posted between 12.01am to 4.59am becomes 24.01 - 28.59 .

    I have consulted the person who created the guestbook but he could not help . I would be very grateful if someone could help.

    Appended below are excerpts of the codes used for setting the time difference:



    <? require("check.php") ;?>
    <?
    if($_POST['ghtml'] != "")
    {
    $gname=str_replace("∥","", $_POST['gname']);
    $gup=str_replace("∥","", $_POST['gup']);
    $guser=str_replace("∥","", $_POST['guser']);
    $gmail=str_replace("∥","", $_POST['gmail']);
    $ghome=str_replace("∥","", $_POST['ghome']);
    $gwidth=str_replace("∥","", $_POST['gwidth']);
    $gn=str_replace("∥","", $_POST['gn']);
    $gnnumber=str_replace("∥","", $_POST['gnnumber']);
    $ghtml=str_replace("∥","", $_POST['ghtml']);
    $gup=str_replace("∥","", $_POST['gup']);
    $gm_link=str_replace("∥","", $_POST['gm_link']);
    $gu_link=str_replace("∥","", $_POST['gu_link']);
    $go_link=str_replace("∥","", $_POST['go_link']);
    $gc_link=str_replace("∥","", $_POST['gc_link']);
    $gm_line=str_replace("∥","", $_POST['gm_line']);
    $gi_line=str_replace("∥","", $_POST['gi_line']);
    $go_skin=str_replace("∥","", $_POST['go_skin']);
    $gm_skin=str_replace("∥","", $_POST['gm_skin']);
    $gc_skin=str_replace("∥","", $_POST['gc_skin']);
    $gf_type=str_replace("∥","", $_POST['gf_type']);
    $gip=str_replace("∥","", $_POST['gip']);
    $gt_y=str_replace("∥","", $_POST['gt_y']);
    $gt_m=str_replace("∥","", $_POST['gt_m']);
    $gt_d=str_replace("∥","", $_POST['gt_d']);
    $gt_h=str_replace("∥","", $_POST['gt_h']);
    $gt_s=str_replace("∥","", $_POST['gt_s']);
    $g_boy=str_replace("∥","", $_POST['g_boy']);
    $g_girl=str_replace("∥","", $_POST['g_girl']);
    $system=$gname."∥".$gup."∥".$guser."∥".$gmail."∥".$ghome."∥".$gwidth."∥".$gnnumber."∥".$gn."∥".$gm_l ink."∥".$gu_link."∥".$go_link."∥".$gc_link."∥".$gm_line."∥".$gi_line."∥".$go_skin."∥".$gm_skin."∥".$ gc_skin."∥".$gf_type."∥".$gip."∥".$gt_y."∥".$gt_m."∥".$gt_d."∥".$gt_h."∥".$gt_s."∥".$g_boy."∥".$g_gi rl."∥".$ghtml;
    $f=fopen("gtype.dat","w+");
    fputs($f,$system);
    fclose($f);
    echo "<table border=0 width=150><tr><td><fieldset><center><br><font color=Red size=2><legend>finish editing</legend></font><a href=javascript:history.back(1)><font color=$gm_link size=2>return to previous page</font></a><hr color=$gu_link width=150 size=1></fieldset></td></tr></table>";
    }
    ?>
    =============================================
    <form action="system.php?cookie=yes" method="post">
    <tr>
    <td width="55%" style="border: 1 solid #C0C0C0"><font size="2">time difference </font></td>
    <td width="47%" style="border: 1 solid #C0C0C0"><font size="2">year:<input type="text" name="gt_y" size="2" value="<?=$gt_y;?>">month:<input type="text" name="gt_m" size="2" value="<?=$gt_y;?>">date:<input type="text" name="gt_d" size="2" value="<?=$gt_d;?>">hour:<input type="text" name="gt_h" size="2" value="<?=$gt_h;?>">minute:<input type="text" name="gt_s" size="2" value="<?=$gt_s;?>"></font></td>
    </tr>

  • #2
    Change this:

    Code:
    <input type="text" name="gt_m" size="2" value="<?=$gt_y;?>">
    to this:

    Code:
    <input type="text" name="gt_m" size="2" value="<?=$gt_[B][COLOR="Red"]m[/COLOR][/B];?>">
    I don't know if that's the only thing wrong with your code, but it's a start.

    BTW, you really need to use code tags to make your code easier to read.
    Music Around The World - Collecting tips, trade and want lists, album reviews, & more

    Comment


    • #3
      Many thanks to you, vinyl-junkie, for highlighting one of the error.
      The codes were actually not written by me but by the creator of the guestbook. I am still a newbie in PHP.

      I change the time difference to -10 in order to test if it works now.
      The current time of the server (USA) which I use is 9 Oct, 4:52am whilst
      the current time of the location where I am situated say, is 8 Oct, 18:52,
      I would need to enter -10 hours to set the TIME DIFFERENCE.

      But the guestbook shows as :9 Oct, -6.52
      Both the date and time is incorrect.
      http://melody.freeprohost.com/guest.php

      Comment


      • #4
        I found this code for fixing time difference for PHP script where the number "15" is the hour difference of 15.
        I wonder if this code is relevant for fixing the error that I encounter?

        $currentDateTime = date("Y-m-d H:i:s", mktime(date("H") + 15, date("i"), date("s"), date("m"), date("d"), date("Y")));

        Comment


        • #5
          Splitting that out into individual variables, here is an example for the hour:

          Code:
          $gt_h = strftime("%H", $currentDateTime);
          You should be able to figure the rest of them out. Also where to place this in your code.
          Music Around The World - Collecting tips, trade and want lists, album reviews, & more

          Comment


          • #6
            Many thanks for the codes, vinyl-junkie . I have done 2 tests below replacing the original codes with the one given (highligted in red)but still didn't work. I wonder where has gone wrong:

            Sorry, I am a real newbie in PHP

            Test1:
            <? require("check.php") ;?>
            <?
            if($_POST['ghtml'] != "")
            {
            $gname=str_replace("∥","", $_POST['gname']);
            $gup=str_replace("∥","", $_POST['gup']);
            $guser=str_replace("∥","", $_POST['guser']);
            $gmail=str_replace("∥","", $_POST['gmail']);
            $ghome=str_replace("∥","", $_POST['ghome']);
            $gwidth=str_replace("∥","", $_POST['gwidth']);
            $gn=str_replace("∥","", $_POST['gn']);
            $gnnumber=str_replace("∥","", $_POST['gnnumber']);
            $ghtml=str_replace("∥","", $_POST['ghtml']);
            $gup=str_replace("∥","", $_POST['gup']);
            $gm_link=str_replace("∥","", $_POST['gm_link']);
            $gu_link=str_replace("∥","", $_POST['gu_link']);
            $go_link=str_replace("∥","", $_POST['go_link']);
            $gc_link=str_replace("∥","", $_POST['gc_link']);
            $gm_line=str_replace("∥","", $_POST['gm_line']);
            $gi_line=str_replace("∥","", $_POST['gi_line']);
            $go_skin=str_replace("∥","", $_POST['go_skin']);
            $gm_skin=str_replace("∥","", $_POST['gm_skin']);
            $gc_skin=str_replace("∥","", $_POST['gc_skin']);
            $gf_type=str_replace("∥","", $_POST['gf_type']);
            $gip=str_replace("∥","", $_POST['gip']);
            $gt_y=str_replace("∥","", $_POST['gt_y']);
            $gt_m=str_replace("∥","", $_POST['gt_m']);
            $gt_d=str_replace("∥","", $_POST['gt_d']);
            $gt_h=str_replace("∥","", $_POST['gt_h']);
            $gt_s=str_replace("∥","", $_POST['gt_s']);
            $g_boy=str_replace("∥","", $_POST['g_boy']);
            $g_girl=str_replace("∥","", $_POST['g_girl']);
            $system=$gname."∥".$gup."∥".$guser."∥".$gmail."∥".$ghome."∥".$gwidth."∥".$gnnumber."∥".$gn."∥".$gm_l ink."∥".$gu_link."∥".$go_link."∥".$gc_link."∥".$gm_line."∥".$gi_line."∥".$go_skin."∥".$gm_skin."∥".$ gc_skin."∥".$gf_type."∥".$gip."∥".$gt_y = strftime("%Y", $currentDateTime);."∥".$gt_m = strftime("%M", $currentDateTime);."∥".$gt_d = strftime("%D", $currentDateTime);."∥".$gt_h = strftime("%H", $currentDateTime);."∥".$gt_s = strftime("%S", $currentDateTime);."∥".$g_boy."∥".$g_girl."∥".$ghtml;
            $f=fopen("gtype.dat","w+");
            fputs($f,$system);
            fclose($f);
            echo "<table border=0 width=150><tr><td><fieldset><center><br><font color=Red size=2><legend>finish editing</legend></font><a href=javascript:history.back(1)><font color=$gm_link size=2>return to previous page</font></a><hr color=$gu_link width=150 size=1></fieldset></td></tr></table>";
            }
            ?>

            Result:
            http://melody.freeprohost.com/guest.php
            message number 5-7

            ================

            Test 2 :
            <form action="system.php?cookie=yes" method="post">
            <tr>
            <td width="55%" style="border: 1 solid #C0C0C0"><font size="2">time difference </font></td>
            <td width="47%" style="border: 1 solid #C0C0C0"><font size="2">year:<input type="text" name="gt_y" size="2" value="<?=$gt_y = strftime("%Y", $currentDateTime);?>">month:<input type="text" name="gt_m" size="2" value="<?=$gt_m = strftime("%M", $currentDateTime);?>">date:<input type="text" name="gt_d" size="2" value="<?=$gt_d = strftime("%D", $currentDateTime);?>">hour:<input type="text" name="gt_h" size="2" value="<?=$gt_h = strftime("%H", $currentDateTime);?>">minute:<input type="text" name="gt_s" size="2" value="<?=$gt_s = strftime("%S", $currentDateTime);?>"></font></td>
            </tr>

            Result:
            http://melody.freeprohost.com/guest.php
            message number 8

            ================
            Last edited by tzinyii; Oct 11, 2006, 12:46 AM.

            Comment


            • #7
              Did you remember to add the line to set the new field as well?

              $currentDateTime = date("Y-m-d H:i:s", mktime(date("H") + 15, date("i"), date("s"), date("m"), date("d"), date("Y")));
              Stephen
              Learn Modern JavaScript - http://javascriptexample.net/
              Helping others to solve their computer problem at http://www.felgall.com/

              Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

              Comment


              • #8
                May I know where should I put this line?
                Do I also need to make other changes to the original codes?
                Many thanks in advance.

                Comment


                • #9
                  Hi vinyl-junkie,
                  any idea where gone wrong?
                  Your assistance would be appreciated.

                  Comment

                  Working...
                  X