Help me set timezone

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

    Help me set timezone

    It's a daily and total counter code.. it using GMT -6 but I want to set GMT 6+
    help me please..

    Code:
    <?php
    $counter = "./counter.txt";
    $today = getdate();
    $month = $today[month];
    $mday = $today[mday];
    $year = $today[year];
    $current_date = $mday . $month . $year;
    // Log visit;
    $fp = fopen($counter, "a");
    $line = $REMOTE_ADDR . "|" . $mday . $month . $year . "\n";
    $size = strlen($line);
    fputs($fp, $line, $size);
    fclose($fp);
    $contents = file($counter);
    $total_hits = sizeof($contents);
    $total_hosts = array();
    for ($i=0;$i<sizeof($contents);$i++) {
    $entry = explode("|", $contents[$i]);
    array_push($total_hosts, $entry[0]);
    }
    $total_hosts_size = sizeof(array_unique($total_hosts));
    $daily_hits = array();
    for ($i=0;$i<sizeof($contents);$i++) {
    $entry = explode("|", $contents[$i]);
    if ($current_date == chop($entry[1])) {
    array_push($daily_hits, $entry[0]);
    }
    }
    $daily_hits_size = sizeof($daily_hits);
    $daily_hosts = array();
    for ($i=0;$i<sizeof($contents);$i++) {
    $entry = explode("|", $contents[$i]);
    if ($current_date == chop($entry[1])) {
    array_push($daily_hosts, $entry[0]);
    }
    }
    $daily_hosts_size = sizeof(array_unique($daily_hosts));
    ?>

    #2
    In this code hour time is not used, it is your server time. Use htacces for that setting.
    <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

    Comment


      #3
      Can you give me the code for htaccess. please?

      Comment


        #4
        Originally posted by almahmud View Post
        Can you give me the code for htaccess. please?
        code of .htaccess file

        Code:
        php_value date.timezone "Europe/Berlin"
        change europe/berlin to your timezone

        if you want to use php, use this function:

        PHP Code:
        date_default_timezone_set("Europe/Berlin"); 
        The full script

        PHP Code:
        <?php
        $counter 
        "./counter.txt";
        #List timeZone For ASIA http://php.net/manual/es/timezones.asia.php
        date_default_timezone_set("Europe/Berlin"); // Timezone > Edit this line to your timezone
        $today getdate();
        $month $today[month];
        $mday $today[mday];
        $year $today[year];
        $current_date $mday $month $year;
        // Log visit;
        $fp fopen($counter"a");
        $line $REMOTE_ADDR "|" $mday $month $year "\n";
        $size strlen($line);
        fputs($fp$line$size);
        fclose($fp);
        $contents file($counter);
        $total_hits sizeof($contents);
        $total_hosts = array();
        for (
        $i=0;$i<sizeof($contents);$i++) {
        $entry explode("|"$contents[$i]);
        array_push($total_hosts$entry[0]);
        }
        $total_hosts_size sizeof(array_unique($total_hosts));
        $daily_hits = array();
        for (
        $i=0;$i<sizeof($contents);$i++) {
        $entry explode("|"$contents[$i]);
        if (
        $current_date == chop($entry[1])) {
        array_push($daily_hits$entry[0]);
        }
        }
        $daily_hits_size sizeof($daily_hits);
        $daily_hosts = array();
        for (
        $i=0;$i<sizeof($contents);$i++) {
        $entry explode("|"$contents[$i]);
        if (
        $current_date == chop($entry[1])) {
        array_push($daily_hosts$entry[0]);
        }
        }
        $daily_hosts_size sizeof(array_unique($daily_hosts));
        ?>
        Correct me if i Wrong..
        Sorry for my bad english

        Comment


          #5
          Very very thanks.. I will try

          Comment

          Working...
          X