Is it possible to add a time stamp if a user creates a new record on a table? I'd like users to be able to add rows, but then be able to see the date that row was added. Is this possible?
Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.
-
For example, If you need a simple auto pre-populate for the column Date and Time, to be the current Date Time,
Then, in the Editor Type, set as "one line edit", and set the predefined editor value as the placeholder %CURRENT_DATETIME% :
And then, if someone tries to add a new row, this column's value will automatically be default as the current date and time :
-
2.
There is also a custom SQL workaround, for SQL tables, if you need a 'timestamp' :
1. Create a column (for example "Updated") in your table
2. In column settings set the type to be "DateTime" (in the "Data" tab), and in the "Editing" tab set the "Editor Input Type" to "none".
3. In the database, run this query:
ALTER TABLE `table_name` CHANGE `updated` `updated` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
Please note that you need to replace 'table_name' with the actual database table name. You can find the database name of the table in the Editing tab above the table, in the "MySQL query name for editing" field.
Is it possible to add a time stamp if a user creates a new record on a table? I'd like users to be able to add rows, but then be able to see the date that row was added. Is this possible?
Hi, Geoffrey
Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.
-
For example, If you need a simple auto pre-populate for the column Date and Time, to be the current Date Time,
we have this placeholder,
that you can use as a predefined editor value.
-
Here is how you can do it :
Set column type to DateTime;
Then, in the Editor Type, set as "one line edit", and set the predefined editor value as the placeholder %CURRENT_DATETIME% :
And then, if someone tries to add a new row, this column's value will automatically be default as the current date and time :
-
2.
There is also a custom SQL workaround, for SQL tables, if you need a 'timestamp' :
1. Create a column (for example "Updated") in your table
2. In column settings set the type to be "DateTime" (in the "Data" tab), and in the "Editing" tab set the "Editor Input Type" to "none".
3. In the database, run this query:
Please note that you need to replace 'table_name' with the actual database table name. You can find the database name of the table in the Editing tab above the table, in the "MySQL query name for editing" field.
-
Let us know if this is helpful. Thank you
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables