Convert Epoch time using filters
-
I am trying to convert the meta_value of one of my meta_keys from Epoch time to a date string. I cannot seem to access the object of the selected meta fields that I choose within the export screen.
Is it possible to filter this data prior to exporting? I also do not want to update the value within the database itself, therefore I’m trying to avoid using update_user_meta().
Here is the function I have created thus far, though I realize “export_user_data_user_field” is probably the wrong object.
function format_expire_date($date) { $users = get_users(); $user_group = array(); foreach ( $users as $user ) { $user_id = $user->ID; $key = '_expire_user_date'; $single = true; $epoch = get_user_meta( $user_id, $key, $single ); $formatted_date = date('d-m-Y H:i:s', $epoch); $date->set( 'meta_key', '_expire_user_date' ); $date->set( 'meta_value', $formatted_date ); } return $date; } add_filter('export_user_data_user_field', 'format_expire_date');
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘Convert Epoch time using filters’ is closed to new replies.