time() - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

time()

firestar_lenefirestar_lene Posts: 33Member
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

  • skylarskylar Posts: 82Member
    : 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]

  • firestar_lenefirestar_lene Posts: 33Member
    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]
    :
    :

  • firestar_lenefirestar_lene Posts: 33Member
    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.