Using PHP given that I have a foreach loop going through via glob to output some images, I would like to extract the date and time the images were uploaded.
I have them named as follows when they are uploaded:
1234567_29052017-122959.jpg
The first sequence of numbers before the _ is an account number, this is to be stripped out. The second sequence of numbers is the date, so 29/05/2017. The third sequence of numbers is the time of day, so 12:29:59. Each filename is output as $image in the foreach below:
$dirname = 'photos/' . $account . '/';
$images = glob($dirname.'*.jpg');
If ($images == null ) {
echo "There was no photos returned for the account number that you entered.";
} else {
foreach($images as $image) {
echo '
<div class="viewerContent" style="width:220px; min-height: 160px;">Insert Date Here <br />
<a href="'.$image.'"><img src="'.$image.'" width="220" height="160" title="'.$image.'" /></a><br />
</div>';
}
}
What I want to is extract the following from the above given example.
1234567_29052017-122959.jpg
To
29/05 12:29:59s
Can anyone assist me in achieving this?
I am going to add the resulting timestamp to the foreach in the Insert Date Here section of the repeating echo.