anon36 Posted October 10, 2008 Share Posted October 10, 2008 I don't know PHP at all, but I am trying to edit just one line just in order to format the date. This is for the photo gallery on my website. The PHP script automatically gets the EXIF data from the jpeg files and displays it on each webpage. The original line is: echo ('<li>Date and time: '.($result[subIFD][DateTimeOriginal] ? trim($result[subIFD][DateTimeOriginal]) : $error).'</li>'); This works correctly and shows the date the photo was taken on. But the format is "2007:10:23 12:53:58", and I want "23 Oct. 2007" or just "Oct. 2007". I looked at the PHP documentation, and tried echo ('<li>Date: '.($result[subIFD][DateTimeOriginal] ? date("j M. Y", strtotime(trim($result[subIFD][DateTimeOriginal]))) : $error).'</li>'); but this gives 31 Dec. 1969. So I tried echo ('<li>Date: '.($result[subIFD][DateTimeOriginal] ? date("j M. Y", strtotime(trim(""+$result[subIFD][DateTimeOriginal]))) : $error).'</li>'); but this gives the present date. Please can anyone help? The gallery I am using is Minimal Gallery, http://minimalgallery.net/home. My site is hosted by freehostia.com, which uses PHP 5. Quote Link to comment https://forums.phpfreaks.com/topic/127886-solved-formatting-exif-date-just-one-line-of-code-help-please/ Share on other sites More sharing options...
Maq Posted October 10, 2008 Share Posted October 10, 2008 Sorry, wrong post :-\ Quote Link to comment https://forums.phpfreaks.com/topic/127886-solved-formatting-exif-date-just-one-line-of-code-help-please/#findComment-662120 Share on other sites More sharing options...
CroNiX Posted October 10, 2008 Share Posted October 10, 2008 There is probably an easier way, but this will work: <?php $tdate=trim($result[subIFD][DateTimeOriginal]); $splitRaw=split(" ", $tdate); $splitDate = split(":", $splitRaw[0]); $newRawDate = mktime(0,0,0,$splitDate[1],$splitDate[2],$splitDate[0]); $newDate = date("j M. Y", $newRawDate); //lookup date() to see other formatting options here echo $newDate; Quote Link to comment https://forums.phpfreaks.com/topic/127886-solved-formatting-exif-date-just-one-line-of-code-help-please/#findComment-662158 Share on other sites More sharing options...
anon36 Posted October 11, 2008 Author Share Posted October 11, 2008 Thank you! That works. Quote Link to comment https://forums.phpfreaks.com/topic/127886-solved-formatting-exif-date-just-one-line-of-code-help-please/#findComment-662549 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.