在字符串中搜索格式化日期并将其替换为当前日期php

I need to search inside the string and replace it with the current date

This what i have tried yet. It works fine, it replaces the date into the current date, but the problem is, that I need the initial date to be dynamic, so i can use any date.

<?php 
    $string = 'we will be held the event in 12/2017 . and waiting for your ..';
    $anydigit = '12/2017';
    $str = str_replace($anydigit,  date(), $string);
    var_dump ($str);

?>
 <div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default>
                <div class="panel-body">
                     <p> we will be held the event in 12/2017 . and waiting for your </p>
                </div>
            </div>
        </div>  
    </div>
 </div>

Sounds like you want a regex: /\d{2}\/\d{4}/

You also need to pass a format to date.

Full code:

$string   = 'we will be held the event in 12/2017 . and waiting for your ..';
$str      = preg_replace('/\d{2}\/\d{4}/', date('Y/m/d'), $string);
var_dump($str);

eval.in demo