Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide variant of EXIF recording time (“%er…”) that considers EXIF time zone where available (EXIF 2.31+) #1

Open
ocram opened this issue Nov 22, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@ocram
Copy link
Contributor

ocram commented Nov 22, 2019

if ($field[0] === 'EXIF' && $field[1] === 'DateTimeOriginal') {
	$utcOffset = !empty($exif['EXIF']['UndefinedTag:0x9011']) ? (string) $exif['EXIF']['UndefinedTag:0x9011'] : null;
}
elseif ($field[0] === 'EXIF' && $field[1] === 'DateTimeDigitized') {
	$utcOffset = !empty($exif['EXIF']['UndefinedTag:0x9012']) ? (string) $exif['EXIF']['UndefinedTag:0x9012'] : null;
}
elseif ($field[0] === 'IFD0' && $field[1] === 'DateTime') {
	$utcOffset = !empty($exif['EXIF']['UndefinedTag:0x9010']) ? (string) $exif['EXIF']['UndefinedTag:0x9010'] : null;
}
else {
	$utcOffset = null;
}

$timeZone = null;

if ($utcOffset !== null) {
	if (\preg_match('/^([+-])([01][0-9]):([0134][05])$/', $utcOffset) === 1) {
		$timeZone = new \DateTimeZone($utcOffset);
	}
}

// $dateTimeObj = ... // add $timeZone as parameter

$dateTimeObj->setTimeZone(new DateTimeZone(\date_default_timezone_get()));

if ($timeOffsetObj !== null) {
	// ...
}
@ocram ocram added the enhancement New feature or request label Nov 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant