PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1847
Number of posts: 5013

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
time() Posted by firestar_lene on 26 May 2004 at 2:13 AM
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?
Report
Re: time() Posted by skylar on 31 May 2004 at 2:10 AM
: 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
Snoochie Boochies

Report
Re: time() Posted by firestar_lene on 1 Jun 2004 at 7:18 PM
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
: Snoochie Boochies
:
:

Report
Re: time() Posted by firestar_lene on 27 Jun 2004 at 6:31 PM
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
: Snoochie Boochies
:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.