Count time from registration date to today

Just gave an example of how to do it: $today_date = new DateTime( date( ‘Y-m-d’, strtotime( ‘today’ ) ) ); $register_date = get_the_author_meta( ‘user_registered’, get_current_user_id() ); $registered = new DateTime( date( ‘Y-m-d’, strtotime( $register_date ) ) ); $interval_date = $today_date->diff( $registered ); if( $interval_date->days < 31 ) { echo ‘With us ‘ . $interval_date->format(‘%d days’); … Read more

How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?

get_post() and get_post_meta() should work to collect the data and array_multisort() should be able to sort it into ascending order. // Query the database to get the posts from your post types $project_args = array( ‘post_type’ => ‘projects’, “numberposts” => -1 ); $task_args = array( ‘post_type’ => ‘tasks’, “numberposts” => -1 ); $material_args = array( … Read more

Apply filters on date format

As per the code reference the_time filter recieves two parameters – $get_the_time and $format. You can use the latter to determine which formatting option to use. add_filter( ‘the_time’, ‘changer_date_format’, 10, 2 ); function changer_date_format( $ladate, $format ) { global $post; if ( ‘d M’ === $format ) { return get_post_time( get_option( ‘date_format’ ), false, $post, … Read more