Time Function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JTM
    Member
    • Jun 2004
    • 31

    #1

    Time Function

    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
    This is your life and it's ending one minute at a time
  • -Oz-
    Senior Member
    • Mar 2004
    • 545

    #2


    Make sure you read the comments.
    Dan Blomberg

    Comment

    • JTM
      Member
      • Jun 2004
      • 31

      #3
      Thank you. I think that will be put to good use.
      This is your life and it's ending one minute at a time

      Comment

      • -Oz-
        Senior Member
        • Mar 2004
        • 545

        #4
        Yeah, using just that page I was able to write a very complicated scheduling program.
        Dan Blomberg

        Comment

        • Skky
          Member
          • Apr 2004
          • 31

          #5
          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:

          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);
          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.

          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

          Working...