$post_date = get_the_date('Y-m-d', $product->get_id()); $post_date_time = strtotime($post_date); $current_date_time = strtotime(current_time('Y-m-d')); $date_diff = ($current_date_time - $post_date_time) / (60 60 24); if ($date_diff <= 30): ?> <span class="new-label">New</span> <?php endif; ?>