3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'Some text bla-bla #date# other text #date# some other #date#'; echo preg_replace_callback('/#date#/', function () { return date('Y-m-d', strtotime( '+'.mt_rand(0,45).' days')); }, $string);

preferences:
47.77 ms | 407 KiB | 5 Q