How to add meta_data entries on CMS WordPress dynamic value age?

Interested in how to add the value of age. Dopustm I have this function:

// 5 - Functions when impermeability, keeping the player
// ======================================================
//
 global $post;
 global $My_False;
 $My_False = ";

 // PLAYER - PLAYER'S AGE ON THE DATE OF BIRTH: 
//
 // Add the meta box _sdstudio_date_of_birth the amount received subtracted from the date of birth
 // ======================================================
 // START


 // Post Carbon Age in the Meta
 add_action( 'carbon_fields_post_meta_container_saved', 'crb_after_save_event' );

 crb_after_save_event function( $post_id) {
 // ----------------------------
 global $post;
 // Here false at the end means that we have an array of data
 $date_of_birth = get_post_meta($post_id, '_sdstudio_date_of_birth', true);
 // Calculate age
 $age = intval(date('Y', time() - strtotime($date_of_birth))) - 1970;
 // If not saved tennis player - go out to smoke, go out really... 
 if ( get_post_type( $post_id ) !== 'ftzo_tennis_player' ) {
 return false;
}
 // If the variable age has the value embrace the monitor, the crying and the value inserted.
 if ( $age ) {
 update_post_meta( $post_id, '_sdstudio_age_field', $age );
}

}
 // ----------------------------
 // END
 // PLAYER - PLAYER'S AGE ON THE DATE OF BIRTH
 // ======================================================


And so the function is all calculated and added its value in the meta data recording. And whether there is an option what age were dynamic? Well, that is, from year to year are updated? After the value was added and therefore it's static.
March 19th 20 at 08:30
1 answer
March 19th 20 at 08:32
Solution
The question is why? Guys to clog the database with unnecessary information. It's all calculated on the fly and instantly load a little more than nothing.

Stupid store date of birth in the form of a timestamp, respectively, to make any selection, and compare it with any time.

Well, if awesome want, you can run your update script once a day such as Crohn's disease, but again, what for
Yes, in fact of the matter is that the purpose of filtering players by age, that this is the problem.... - yasmeen_Feest commented on March 19th 20 at 08:35
@yasmeen_Feest, Well date of birth, the current date is what the problem is to choose only what is suitable for the desired interval? - Hug commented on March 19th 20 at 08:38
Well, OK, but when the players are about 1000, WP starts to hang and wildly to mock nerves. In any case, very grateful for Your answers. Went to cut Carbon Fields. - yasmeen_Feest commented on March 19th 20 at 08:41

Find more questions by tags WordPress