time()

is it possible that when i save data using time(),which the time was in pm and then when display, it is in am?is this error possible to happen because i didnt set it in according the time zone?

Comments

  • : is it possible that when i save data using time(),which the time was in pm and then when display, it is in am?is this error possible to happen because i didnt set it in according the time zone?
    :


    No, that is impossible :) Unless you are doing some buggy calculations on it there should be no discrempentcy AT ALL.

    The time() value comes STRAIGHT from your server. It has NOTHING to do with user's computers or the users themselves.


    A handy feature i use often is to allow users to choose their current timezone (or GMT offset) from a preferences page.

    When they login.. i put it in a cookie.. then on every page that needs it (forums make best use of this)

    So if you read the cookie.. and put that time offset into a variable called something like $timeoffset
    $timeoffset = $HTTP_SESSION_VARS['somesessionname'];
    or
    $timeoffset = $HTTP_COOKIE_VARS['somecookiename'];

    You can do this for time:

    $q = mysql_query("SELECT timeofpost FROM posts_table WHERE .. blah blah blah");
    $data = mysql_fetch_row($q);
    $time = $data[0];

    $newtime = $time + ($timeoffset * 86400);


    So if the users time offset is -5 then time is -432000 seconds behind YOUR SERVER TIME (sometimes it is not GMT so you must check to see if it is)

    Then obviously to show the time:
    $timestring = date("blah blah", $time);
    echo $timestring;


    * sorry i tend to go a little far on my explinations and just add things that aren't always necessary :P
    [b][blue]Snoochie Boochies[/blue][/b]

  • ok..thanks

    : : is it possible that when i save data using time(),which the time was in pm and then when display, it is in am?is this error possible to happen because i didnt set it in according the time zone?
    : :
    :
    :
    : No, that is impossible :) Unless you are doing some buggy calculations on it there should be no discrempentcy AT ALL.
    :
    : The time() value comes STRAIGHT from your server. It has NOTHING to do with user's computers or the users themselves.
    :
    :
    : A handy feature i use often is to allow users to choose their current timezone (or GMT offset) from a preferences page.
    :
    : When they login.. i put it in a cookie.. then on every page that needs it (forums make best use of this)
    :
    : So if you read the cookie.. and put that time offset into a variable called something like $timeoffset
    : $timeoffset = $HTTP_SESSION_VARS['somesessionname'];
    : or
    : $timeoffset = $HTTP_COOKIE_VARS['somecookiename'];
    :
    : You can do this for time:
    :
    : $q = mysql_query("SELECT timeofpost FROM posts_table WHERE .. blah blah blah");
    : $data = mysql_fetch_row($q);
    : $time = $data[0];
    :
    : $newtime = $time + ($timeoffset * 86400);
    :
    :
    : So if the users time offset is -5 then time is -432000 seconds behind YOUR SERVER TIME (sometimes it is not GMT so you must check to see if it is)
    :
    : Then obviously to show the time:
    : $timestring = date("blah blah", $time);
    : echo $timestring;
    :
    :
    : * sorry i tend to go a little far on my explinations and just add things that aren't always necessary :P
    : [b][blue]Snoochie Boochies[/blue][/b]
    :
    :

  • thansk anyway..i have solve my problem

    : : is it possible that when i save data using time(),which the time was in pm and then when display, it is in am?is this error possible to happen because i didnt set it in according the time zone?
    : :
    :
    :
    : No, that is impossible :) Unless you are doing some buggy calculations on it there should be no discrempentcy AT ALL.
    :
    : The time() value comes STRAIGHT from your server. It has NOTHING to do with user's computers or the users themselves.
    :
    :
    : A handy feature i use often is to allow users to choose their current timezone (or GMT offset) from a preferences page.
    :
    : When they login.. i put it in a cookie.. then on every page that needs it (forums make best use of this)
    :
    : So if you read the cookie.. and put that time offset into a variable called something like $timeoffset
    : $timeoffset = $HTTP_SESSION_VARS['somesessionname'];
    : or
    : $timeoffset = $HTTP_COOKIE_VARS['somecookiename'];
    :
    : You can do this for time:
    :
    : $q = mysql_query("SELECT timeofpost FROM posts_table WHERE .. blah blah blah");
    : $data = mysql_fetch_row($q);
    : $time = $data[0];
    :
    : $newtime = $time + ($timeoffset * 86400);
    :
    :
    : So if the users time offset is -5 then time is -432000 seconds behind YOUR SERVER TIME (sometimes it is not GMT so you must check to see if it is)
    :
    : Then obviously to show the time:
    : $timestring = date("blah blah", $time);
    : echo $timestring;
    :
    :
    : * sorry i tend to go a little far on my explinations and just add things that aren't always necessary :P
    : [b][blue]Snoochie Boochies[/blue][/b]
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

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

Categories