PDA

View Full Version : Time and date at the server


rjordan
02-01-2005, 09:57 PM
How would I go about getting the time and date at the server regardless of who is logged in? I have seen the following:

$date = vbdate($vboptions['dateformat'], TIMENOW);
$time = vbdate($vboptions['timeformat'], TIMENOW);Assume that me and someone an hour ahead of me run the above code at the same time. When I log in, I am in the same time zone as the server. If someone an hour ahead of me logs in, the above code gives an hour difference.

Is there a magic way to craft the above code to give me the results I am looking for?

Jolten
02-01-2005, 10:40 PM
yes that code will give the user the correct current time based upon their offset values.

rjordan
02-02-2005, 12:47 AM
yes that code will give the user the correct current time based upon their offset values.While I appreciate the reply, that is why I am asking for assistance. I would like to have it based off of the settings in AdminCP to return something like 5:48pm EST or similar if at all possible.

Jolten
02-02-2005, 01:59 AM
If you just want the server time you can use the following

$dtnow = date(m-d-Y H:i:s);


Then just use print $dtnow; or echo $dtnow; to call the time.

That will return 02-02-2005 13:25:23.

Then you can add the EST or whatever.

For more date options try www.php.net

rjordan
02-02-2005, 02:33 AM
Thanks for the input, but I was PMed with this solution (which I thought I would share if the question were to come up again). It seems to work as requested.


$date = vbdate($vboptions['dateformat'], TIMENOW, 0, 1, 0, 0);
$time = vbdate($vboptions['timeformat'], TIMENOW, 0, 1, 0, 0);