Unix timestamp update

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dr zoidberg

    #1

    Unix timestamp update

    Hello,

    I'm creating login using PHP/MySQL. I have Unix Timestamp (eg.
    1005882301). What will be the easiest way to update this filed to
    current date/time everytime when user log in? Should I rather use some
    other mysql date/time field type?

    TNX

  • Shawn Wilson

    #2
    Re: Unix timestamp update

    dr zoidberg wrote:[color=blue]
    >
    > I'm creating login using PHP/MySQL. I have Unix Timestamp (eg.
    > 1005882301). What will be the easiest way to update this filed to
    > current date/time everytime when user log in? Should I rather use some
    > other mysql date/time field type?[/color]

    if (/*User login is successful*/)
    mysql_query("UP DATE accounts SET lastlogin = ".time()." WHERE userid =
    $userid");

    Change variables and use security checks as appropriate.

    Shawn
    --
    Shawn Wilson
    shawn@glassgian t.com

    Comment

    • Geoff Berrow

      #3
      Re: Unix timestamp update

      I noticed that Message-ID: <ISJ3c.3772$%k. 23508@ns45.bih. net.ba> from dr
      zoidberg contained the following:
      [color=blue]
      >I'm creating login using PHP/MySQL. I have Unix Timestamp (eg.
      >1005882301). What will be the easiest way to update this filed to
      >current date/time everytime when user log in? Should I rather use some
      >other mysql date/time field type?[/color]

      strtotime("now" ) is pretty easy.

      --
      Geoff Berrow (put thecat out to email)
      It's only Usenet, no one dies.
      My opinions, not the committee's, mine.
      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

      Comment

      • Tim Van Wassenhove

        #4
        Re: Unix timestamp update

        On 2004-03-10, dr zoidberg <user@domain.in vald> wrote:[color=blue]
        > Hello,
        >
        > I'm creating login using PHP/MySQL. I have Unix Timestamp (eg.
        > 1005882301). What will be the easiest way to update this filed to
        > current date/time everytime when user log in? Should I rather use some
        > other mysql date/time field type?[/color]

        Just use mysql's NOW() function.

        UPDATE table SET timestamp=NOW() WHERE user_id=$user_i d

        --

        Comment

        Working...