From the CFDB Options page, you can set the data format based on PHP Date but I don’t think there is any kind of of option for “ago”.
To accomplish this, you would need to add a transform function, something like this in your short code:
[cfdb-table form="your-form" trans="agotime(submit_time)" hide="Submitted"]
then you would have to code that agotime function as a custom transform function
That can be used in short codes but not in the admin page view.
Thank you for the fast response!
I found this function to convert the time in a post, using a wordpress native function. Could this be modified so it would work for the time field in the table?
function time_ago( $type = 'post' ) {
$d = 'comment' == $type ? 'get_comment_time' : 'get_post_time';
return human_time_diff($d('U'), current_time('timestamp')) . " " . __('ago');
}
As a non-coder I don’t really have an overview of how much time it would take to get this working. If this is too time consuming to figure out for you, I understand!
OK, this won’t be that hard.
In the Add Actions and Filters plugin (Tools -> Add Actions and Filters), add this code:
require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBPermittedFunctions.php');
cfdb_register_function('human_time_diff');
Then make your short code something like this:
[cfdb-table form="Form-Name" hide="now" trans="now=time()&&ago=human_time_diff(submit_time,now)"]
That worked perfectly! Thank you so much! If I may bother you one last time.
Could I add something in there to make it say ‘ago’? For example it would now say ‘4 hours’, and I was wondering if the transform could make it say ‘4 hours ago’.
[cfdb-table form="Form-Name" hide="now,ago1" trans="now=time()&&ago1=human_time_diff(submit_time,now)&&ago= concat(ago1,' ago')"]
It the latest update, you no longer need to add the code in Add Actions and Filters. Just use human_time_diff in the short code.