Sorry guys I always seem to post threads, asking for help with coding. Well heres another one. Does anyone have a site that explains time functions. In a text bases game it would be called a "tick". Im sure if anyone has a site explaining how to use it they know what it is. Thank you in advance for helping me out
Time Function
Collapse
X
-
The time() function is another useful one. UNIX records time as an integer (often referred to as a timestamp), which is the number of seconds since 1970. The time() function creates a timestamp for the current time. So.. you could save the result of time() into a database or file, and then recall it later and display it in English using the date function. This is useful for a lot of things like news scripts, logs, ect. This would be the general layout:
Obviously, it would need to be revised depending on what you are trying to do, but I find it very useful for keeping track of when things happen.Code:// Script 1 - saving the current time $curtime = time(); mysql_query("INSERT into $sometable SET curtime=$curtime"); // Script 2 - recalling and displaying the past, recorded time $query = mysql_query("SELECT curtime FROM blah blah blah"); $submitdate = mysql_result($query, $a_result_row, $curtime); echo date('date format', $submitdate);
NOTE: When learning to code in PHP, I highly recommend roaming around the manual at php.net. While doing so, also check out for the "SEE ALSO" functions at the bottom of each function description to make sure the one you are looking at the best function for what you want to do.Last edited by Skky; 07-29-2004, 06:21 PM.Comment
Comment