nickdejaeger
nickdejaeger

Reputation: 1

Store time() as timestamp in mysql

How to store the current time (as in time()) into the mysql database as a timestamp?

I tried this query:

UPDATE users 
  SET last_login = '1360826987' 
  WHERE username = 'test' 
   AND password = 'test'

where 1360826987 is my current time via time()

Upvotes: 0

Views: 113

Answers (3)

Savas Vedova
Savas Vedova

Reputation: 5692

Use the NOW function of mysql instead.

UPDATE users SET last_login = NOW() ...

Upvotes: 3

Ripa Saha
Ripa Saha

Reputation: 2540

timestamp fields stores value in 2013-02-14 13:10:41 this format. so use now() in your query

Upvotes: 0

Zevi Sternlicht
Zevi Sternlicht

Reputation: 5399

That should work. But make sure that the field accepts Integers.

 Type INT

Upvotes: 0

Related Questions