Two ways to solve this problem come to mind.
The first is to just treat this as an array. It's a dirty solution, but it will work. All strings are really array's of characters. So if
$stamp = '20010506223300';
then you could do:
$year = $stamp[0] . $stamp[1] . $stamp[2] . $stamp[3];
$month = $stamp[4] . $stamp[5];
$day = $stamp[6] . $stamp[7];
$hour = $stamp[8] . $stamp[9];
$minute = $stamp[10] . $stamp[11];
$second = $stamp[12] . $stamp[13];
This is going to slow things down though... and is a really poor solution. My other recomendation works faster, and provides a bit of error checking. It uses a regular expression:
if (ereg("([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})",$stamp,$out)) {
$year = $out[1];
$month = $out[2];
$day = $out[3];
$hour = $out[4];
$minute = $out[5];
$second = $out[6];
}
Be careful with this one, because the first array element (in index 0) is the full $stamp string itself.
Hope this helps,
Curts