Jump to content

read_exif_data question


Skipjackrick

Recommended Posts

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.';
      }
?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.