PHP Class lsolesen\pel\PelEntryTime

This class can hold a timestamp, and it will be used as in this example where the time is advanced by one week: $entry = $ifd->getEntry(PelTag::DATE_TIME_ORIGINAL); $time = $entry->getValue(); print('The image was taken on the ' . date('jS', $time)); $entry->setValue($time + 7 * 24 * 3600); The example used a standard UNIX timestamp, which is the default for this class. But the Exif format defines dates outside the range of a UNIX timestamp (about 1970 to 2038) and so you can also get access to the timestamp in two other formats: a simple string or a Julian Day Count. Please see the Calendar extension in the PHP Manual for more information about the Julian Day Count.
Author: Martin Geisler ([email protected])
Inheritance: extends lsolesen\pel\PelEntryAscii
Datei anzeigen Open project: lsolesen/pel Class Usage Examples

Public Methods

Method Description
__construct ( $tag, $timestamp, $type = self::UNIX_TIMESTAMP ) Make a new entry for holding a timestamp.
convertGregorianToJd ( integer $year, integer $month, integer $day ) : integer Converts a date in year/month/day format to a Julian Day count.
convertJdToGregorian ( $jd ) : array Converts a Julian Day count to a year/month/day triple.
convertJdToUnix ( integer $jd ) : mixed Converts a Julian Day count to a UNIX timestamp.
convertUnixToJd ( integer $timestamp ) : integer Converts a UNIX timestamp to a Julian Day count.
getValue ( $type = self::UNIX_TIMESTAMP ) : integer Return the timestamp of the entry.
setValue ( $timestamp, $type = self::UNIX_TIMESTAMP ) Update the timestamp held by this entry.

Method Details

__construct() public method

Make a new entry for holding a timestamp.
public __construct ( $tag, $timestamp, $type = self::UNIX_TIMESTAMP )

convertGregorianToJd() public method

Converts a date in year/month/day format to a Julian Day count.
public convertGregorianToJd ( integer $year, integer $month, integer $day ) : integer
$year integer the year.
$month integer the month, 1 to 12.
$day integer the day in the month.
return integer the Julian Day count.

convertJdToGregorian() public method

Converts a Julian Day count to a year/month/day triple.
public convertJdToGregorian ( $jd ) : array
return array an array with three entries: year, month, day.

convertJdToUnix() public method

Converts a Julian Day count to a UNIX timestamp.
public convertJdToUnix ( integer $jd ) : mixed
$jd integer the Julian Day count.
return mixed $timestamp the integer timestamp or false if the day count cannot be represented as a UNIX timestamp.

convertUnixToJd() public method

Converts a UNIX timestamp to a Julian Day count.
public convertUnixToJd ( integer $timestamp ) : integer
$timestamp integer the timestamp.
return integer the Julian Day count.

getValue() public method

The timestamp held by this entry is returned in one of three formats: as a standard UNIX timestamp (default), as a fractional Julian Day Count, or as a string.
public getValue ( $type = self::UNIX_TIMESTAMP ) : integer
return integer the timestamp held by this entry in the correct form as indicated by the type argument. For {@link UNIX_TIMESTAMP} this is an integer counting the number of seconds since January 1st 1970, for {@link EXIF_STRING} this is a string of the form 'YYYY:MM:DD hh:mm:ss', and for {@link JULIAN_DAY_COUNT} this is a floating point number where the integer part denotes the day count and the fractional part denotes the time of day (0.25 means 6:00, 0.75 means 18:00).

setValue() public method

Update the timestamp held by this entry.
public setValue ( $timestamp, $type = self::UNIX_TIMESTAMP )