Add leading zero to current post display

I am using the next to show in a loop of posts the current post and the total of posts published.

$post_query = new WP_Query($args);

$postAmount = wp_count_posts( 'post' )-publish;

?php echo $post_query-current_post + 1 ? / ?php echo $postAmount ?

This returns 1/20, 2/20, etc

Does someone know how to add a leading zero so it shows 01/20, 02/20, etc?

Thanks a lot in advance

Topic loop Wordpress

Category Web


should work with sprintf('%02d', $post_query->current_post + 1)

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.