- substr: documentation ( source)
- str_replace: documentation ( source)
<?php
$filename = "2014-01-12-a23ert78df23456ewr91234df789dfh456hj912er.txt";
$date = substr($filename, 0, 10); // 2014-01-02
$path = str_replace("-","/",$date); // 2014/01/02
echo $path;