Results 1 to 5 of 5

Thread: $gdate

  1. #1
    Join Date
    Apr 2001
    Location
    Il
    Posts
    448

    $gdate

    $gdate = date("F.d.Y G:i A"); this works but when the time is posted it shows say like 7 am when it should show 10 am how do I add 3 hours to it?
    http://www.realwebhost.net
    http://www.realwebhost.net/vps.php
    ICQ 120397604 |MSN : hotmail.com | AIM : rwhsupport | Yahoo: rwhmax

  2. #2
    Join Date
    Jul 2002
    Location
    New Hampshire
    Posts
    154
    I found this on the online php documentation:

    /*
    $current should be the timezone on the
    current machine, $target is the timezone
    you want to calculate. Both should be in
    hours. For example, GMT -05:00 should
    be -5. GMT +12:00 should be 12. You can
    use the returned timestamp with the date
    function.

    ex: echo date('r', zonechange(-5, 10));
    would echo the date for a +10:00
    timezone on a machine in -05:00.
    */

    function zonechange ($current, $target) {
    $current = -1 * $current;
    $zonedate = mktime(date('G'), date('i'), date('s'), date('n'),
    date('j'), date('Y'), 1) + (($current + $target) * 3600);
    return $zonedate;
    }
    echo date('r', zonechange(-7, -5));


    ?>

    This works for my hosted server because they are in GMT -0700 and I like my times shown in EST (-0500)

    Its output looks something like this:

    Sun, 11 Aug 2002 12:50:57 -0600

    but you an modify as needed.
    Sadistikal
    When you say "I wrote a program that crashed Windows", people just stare at
    you blankly and say "Hey, I got those with the system, *for free*".
    -- Linus Torvalds

  3. #3
    Join Date
    Apr 2001
    Location
    Il
    Posts
    448
    Below Is the file I tried what you had in place of what I had there but it did not move time and data to index.php page. Somehow we need to take your coding and make that result be qdate

    PHP Code:
    <?

       

    error_reporting
    (0);


    $fp fopen ("msg.txt""r+");
    $fileBuff fread($fpfilesize("msg.txt"));
    rewind($fp); 


    $gdate date("F.d.Y G:i A");                 

    $name strip_tags($name);
    $email strip_tags($email);
    $comment strip_tags($comment);

    require(
    "cfg.php");

    if(!(
    strlen(trim($email)))) { 
    $email "";
    }
    else {
    $email "<a href=mailto:$email>";
    }


    $comment preg_replace('\'(.*)(?<!=|\])([url]http://[/url][A-Za-z0-9@/&\\$%_=\.:]+)(.*)\'','\\1<a href=\\2 target=_blank>\\2</a>\\3',$comment);

    $comment preg_replace("/(([\w\.]+))(@)([\w\.]+)\b/i","<a href=mailto:$0>$0</a>",$comment);


    if (
    $dcode == "yes") {
    $comment str_replace("[b]""<b>"$comment);
    $comment str_replace("[/b]""</b>"$comment);

    $comment str_replace("[i]""<i>"$comment);
    $comment str_replace("[/i]""</i>"$comment);

    $comment str_replace("[u]""<u>"$comment);
    $comment str_replace("[/u]""</u>"$comment);

    }

    if (
    $images == "yes") {
    $comment preg_replace("'\[img=(.*)\]'",'<img src=$1>',$comment);

    }

    if(!(
    strlen(trim($comment)))) { 

    exit(
    "

    <html>

    <head>
    <title>D-Book: Error</title>
    <link REL=stylesheet HREF=style.css TYPE=text/css>
    </head>

    <body bgcolor=
    $bgcolor background=$bgimg>

    <table cellpadding=0 cellspacing=0 border=0 align=center height=85%>
      <tr align=center valign=middle>
        <td><table cellpadding=10 cellspacing=0 border=0 align=center id=table1>
          <tr>
            <td valign=middle align=center id=row1><br>
            <br>
            <font id=text3> You have to add some comments. Please go <a href=index.php>back</a></font>. <br>
            <br>
            <br>
            </td>
          </tr>
        </table>
        </td>
      </tr>
    </table>
    </body>
    </html>

    "
    );
    }
    else {

    $comment wordwrap$comment80"\n"1);
    fwrite($fp,'<table border=0 width=100% cellspacing=0 cellpadding=0
    id=table1><tr><td width=100% id=row1><small><font id=text1><strong>'
    );

    fwrite($fp,$email.''.$name.'</a></strong>
    : '
    );

    fwrite($fp,''.$gdate.'</font></small></td></tr>');

    fwrite($fp,'<tr>
        <td width=100% id=row2><pre><font id=text2>'
    .$comment.'</tr></table>


    '
    );
    fwrite($fp,$fileBuff);
    fclose($fp);
    }

    ?>

    <html>
    <head>
    <link REL='stylesheet' HREF='style.css' TYPE='text/css'>
    <title>Success!</title>
    <meta http-equiv="refresh" content="2; url=index.php">
    </head>

    <body background="<?echo($bgimg);?>" bgcolor="<?echo($bgcolor);?>">

    <table cellpadding='0' cellspacing='0' border='0' align='center' height='85%'>
      <tr align='center' valign='middle'>
        <td><table cellpadding='10' cellspacing='0' border='0' align='center' id='table1'>
          <tr>
            <td valign='middle' align='center' id='row1'><br>
            <br>
            <font id=text3>Your comments have beed added!<br>Click <a href='index.php'>here</a> if your browser did not redirect you. </font><br>
            <br>
            <br>
            </td>
          </tr>
        </table>
        </td>
      </tr>
    </table>
    </body>
    </html>
    http://www.realwebhost.net
    http://www.realwebhost.net/vps.php
    ICQ 120397604 |MSN : hotmail.com | AIM : rwhsupport | Yahoo: rwhmax

  4. #4
    Join Date
    Jul 2002
    Location
    New Hampshire
    Posts
    154
    $qdate = date('r', zonechange(-7, -5));

    should work...assuming the zones are correct...you could modify how it is output in the zonechange function itself.
    Sadistikal
    When you say "I wrote a program that crashed Windows", people just stare at
    you blankly and say "Hey, I got those with the system, *for free*".
    -- Linus Torvalds

  5. #5
    Join Date
    Apr 2001
    Location
    Il
    Posts
    448
    Guy from vb gave the following that works. Thank you guys for helping.
    PHP Code:
    $gdate date("F.d.Y G:i A"time() + (60 60 3) ); 
    http://www.realwebhost.net
    http://www.realwebhost.net/vps.php
    ICQ 120397604 |MSN : hotmail.com | AIM : rwhsupport | Yahoo: rwhmax

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •