Skipjackrick Posted January 28, 2010 Share Posted January 28, 2010 So I am trying to keep these guys from uploading old photos and saying they are fresh. I've got this neat php function that I am using to do so. However I can't seem to get it to work. Can you guys review my code and tell me what's up? <?php $directory = $_SERVER['DOCUMENT_ROOT']; $image = "example.jpg"; $exif_data = exif_read_data ('' . $directory . '/submitted_pics/' . $image . ''); $edate = $exif_data['DateTime']; $start= "2010:01:01 00:00:01"; //FYI $edate outputs in this format 2010:01:01 00:00:01 if( $edate < $start) { $errorCount += 1; if( $errorCount > 1 ) {$errorMessage .= ', '; } $errorMessage .= 'Sorry, the meta data, Date and Time for the image you have submitted is not within the specified duration. Please be sure that the time and date are accurately set on your camera.'; } ?> Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted January 28, 2010 Share Posted January 28, 2010 You can't just compare time "strings" with php. you need to do something like strtotime() on the dates then compare them. Quote Link to comment Share on other sites More sharing options...
Skipjackrick Posted January 28, 2010 Author Share Posted January 28, 2010 You can't just compare time "strings" with php. you need to do something like strtotime() on the dates then compare them. Doesn't that function return something like this? <?php $start= "2010:01:01 00:00:00"; $strtotime = strtotime($start); echo "$strtotime"; // Out put is January 1st 2010 edit: I was incorrect....it actually outputs this 1262329200 ?> .... but I get your drift. Does anybody have an example of how I could compare dates correctly? Quote Link to comment Share on other sites More sharing options...
Skipjackrick Posted January 28, 2010 Author Share Posted January 28, 2010 Ah...I used strtotime() and its works perfect. Thanks! Quote Link to comment 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.