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
https://forums.phpfreaks.com/topic/190150-read_exif_data-question/
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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.