Get WordPress Image ID By URL

To programmatically assign an image to a post as the featured image you need to use the function set_post_thumbnail(), which takes two parameters a post ID and the attachment ID.

set_post_thumbnail( $postId, $attachmentId );

Calculate Days, Month, Years From Date of Birth

$bday = new DateTime($user_birth_date);  // day.month.year (or: year-month-day)
                $now = new DateTime('00:00:00');       // current date-time
               
                $diff = $now->diff($bday);

                $age_year = $diff->y;
                $age_month = $diff->m;
                $age_days = $diff->d;