Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php: current_timestamp for database field?

Tags:

php

timestamp

i'm trying to add a database field called "lastLogin" which should populate each time someone will log in. there's an error when trying to add the field:

#1294 - Invalid ON UPDATE clause for 'lastLogin' column 

i'm not sure what's wrong - i'm having the following settings in phpmyadmin:

field: lastlogin
type: date
standard: none
attribute: on update CURRENT_TIMESTAMP

any idea what's wrong?

thanks

like image 936
Fuxi Avatar asked Feb 25 '23 12:02

Fuxi


1 Answers

Your field type is set to date should be timestamp or datetime.

The DATETIME type is used when you need values that contain both date and time information. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.

The TIMESTAMP data type has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC. It has varying properties, depending on the MySQL version and the SQL mode the server is running in. These properties are described later in this section.

like image 186
msmafra Avatar answered Mar 07 '23 02:03

msmafra