PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Well, I'm also letting the user customize the format of the date, so 12:58, 11-09-2003 won't always be static. Problems would start then. The time is drawn from a mysql timestamp.
So is there anyway around this method, since then the user would have to be stuck with a 24 hour time which imho, many don't like. I tried googling for this kind of a situation didn't have much luck <_<.
Any suggestions?
Thanks,
-Nay
Last edited by Nay on Wed Dec 03, 2003 2:07 am, edited 1 time in total.
<?php
$time = mktime(12,58,00,11,9,2003);
//To get number of seconds needed to find desired time you first need to know how many hours away they are. You should probably store this number in the database along with their use information or how ever you are storing info about that person.
$hours = ($hour*60*60); //60 minutes per hour, 60 seconds per minute
//Next subtract or add the seconds to the overall time
$time += $hours;
echo date("g:i a m/d/Y", $time);
?>
This is a very rough idea. I don't know if you can add a negative number and still get the same result as subtracting a positive with PHP. I haven't had to do that. If so you're done. If not, you need to determine if they are less hours away or more hours away and subtract or add accordingly.
That is just one way. Using math might be the better way to go if there server is not on GMT. I'm not sure how this would behave is the server was set to some local time.
As far formatting the date, check out your Profile on this board and notice how phpBB does it. There is a section in your profile where you define the format using the standard PHP date () syntax. Just do that, and again drop it into a variable for that user. You would obviously need to store all these settings in a database somewhere.
Adds setting to the server environment. The environment variable will only exist for the duration of the current request. At the end of the request the environment is restored to its original state.
So I wondered, what's different with using sessions? O_o