Abhi
Abhi

Reputation: 5561

How to update MySQL timestamp column to current timestamp?

I want to update the columns of data type timestamp manually through my PHP code.

How to do that?

Upvotes: 47

Views: 150314

Answers (2)

Harry Joy
Harry Joy

Reputation: 59660

Use this query:

UPDATE `table` SET date_date=now();

Upvotes: 92

Madbreaks
Madbreaks

Reputation: 19539

Another option:

UPDATE `table` SET the_col = current_timestamp

Looks odd, but works as expected. If I had to guess, I'd wager this is slightly faster than calling now().

Upvotes: 21

Related Questions