Web Analytics Made Easy -
StatCounter insert retrieve timestamp - CodingForum

Announcement

Collapse
No announcement yet.

insert retrieve timestamp

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • insert retrieve timestamp

    Hi there. I want to know how i can insert the current time in a timestamp field. I tried to pass the null string "" but i think it does no make any sense the result.
    After i insert the time how i can retrieve it back?
    Thx

  • #2
    - If you just let out the timestamp column (if it is the first timestamp column) it inserts the timestamp automatically.

    INSERT INTO table (field1, field2, ...) VALUES (value1, value2, ...)

    - You can use NOW(), too.

    Both methods will insert the MySQL Timestamp, which is recommandable.

    If you want to use the php timestamp...
    --> www.php.net/time

    Saludo
    piz
    www.united-scripts.com
    www.codebattles.org

    Comment


    • #3
      insert : http://www.codingforum.net/showthrea...threadid=33965

      After i insert the time how i can retrieve it back?
      Just select it You can then apply the mySQL formatting function ( http://www.mysql.com/doc/en/Date_and...functions.html ) on it inside your selectquery, or apply the php functions when you proces the recordset( http://be2.php.net/manual/en/ref.datetime.php ).

      You'll probably best first convert it to a unixtimestamp like
      PHP Code:
      /*From the php manual. Usercomment on strtotime()
      scott at pigandcow dot com
      29-Dec-2003 03:54 
      Unfortunately, strtotime() can't convert mysql timestamps 
      of the form YYYYMMDDhhmmss (the default 14 character timestamp).  
      Here's a function to do it for you:*/
      function convert_timestamp ($timestamp$adjust="") {
         
      $timestring substr($timestamp,0,8)." ".
                       
      substr($timestamp,8,2).":".
                       
      substr($timestamp,10,2).":".
                       
      substr($timestamp,12,2);
         return 
      strtotime($timestring.$adjust");

      and then you can use it inside all php date-time functions.
      Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

      Comment


      • #4
        xm...

        please take a look at my query
        INSERT INTO Session VALUES("0","192.168.64.11"," now() ")


        This inserts the value 00000000 to the timestamp field......
        What is wrong with it?

        Comment


        • #5
          Please post your question in only one forum. It has already been answered in the mySQL forum (thread from my previous post)
          Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

          Comment

          Working...
          X