wp_get_media_creation_timestamp

The timeline below displays how wordpress function wp_get_media_creation_timestamp has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Parses creation date from media metadata.
 *
 * The getID3 library doesn't have a standard method for getting creation dates,
 * so the location of this data can vary based on the MIME type.
 *
 * @since 4.9.0
 *
 * @link https://github.com/JamesHeinrich/getID3/blob/master/structure.txt
 *
 * @param array $metadata The metadata returned by getID3::analyze().
 * @return int|false A UNIX timestamp for the media's creation date if available
 *                   or a boolean FALSE if a timestamp could not be determined.
 */
function wp_get_media_creation_timestamp($metadata)
{
    $creation_date = false;
    if (empty($metadata['fileformat'])) {
        return $creation_date;
    }
    switch ($metadata['fileformat']) {
        case 'asf':
            if (isset($metadata['asf']['file_properties_object']['creation_date_unix'])) {
                $creation_date = (int) $metadata['asf']['file_properties_object']['creation_date_unix'];
            }
            break;
        case 'matroska':
        case 'webm':
            if (isset($metadata['matroska']['comments']['creation_time'][0])) {
                $creation_date = strtotime($metadata['matroska']['comments']['creation_time'][0]);
            } elseif (isset($metadata['matroska']['info'][0]['DateUTC_unix'])) {
                $creation_date = (int) $metadata['matroska']['info'][0]['DateUTC_unix'];
            }
            break;
        case 'quicktime':
        case 'mp4':
            if (isset($metadata['quicktime']['moov']['subatoms'][0]['creation_time_unix'])) {
                $creation_date = (int) $metadata['quicktime']['moov']['subatoms'][0]['creation_time_unix'];
            }
            break;
    }
    return $creation_date;
}

WordPress Version: 5.9

/**
 * Parse creation date from media metadata.
 *
 * The getID3 library doesn't have a standard method for getting creation dates,
 * so the location of this data can vary based on the MIME type.
 *
 * @since 4.9.0
 *
 * @link https://github.com/JamesHeinrich/getID3/blob/master/structure.txt
 *
 * @param array $metadata The metadata returned by getID3::analyze().
 * @return int|false A UNIX timestamp for the media's creation date if available
 *                   or a boolean FALSE if a timestamp could not be determined.
 */
function wp_get_media_creation_timestamp($metadata)
{
    $creation_date = false;
    if (empty($metadata['fileformat'])) {
        return $creation_date;
    }
    switch ($metadata['fileformat']) {
        case 'asf':
            if (isset($metadata['asf']['file_properties_object']['creation_date_unix'])) {
                $creation_date = (int) $metadata['asf']['file_properties_object']['creation_date_unix'];
            }
            break;
        case 'matroska':
        case 'webm':
            if (isset($metadata['matroska']['comments']['creation_time'][0])) {
                $creation_date = strtotime($metadata['matroska']['comments']['creation_time'][0]);
            } elseif (isset($metadata['matroska']['info'][0]['DateUTC_unix'])) {
                $creation_date = (int) $metadata['matroska']['info'][0]['DateUTC_unix'];
            }
            break;
        case 'quicktime':
        case 'mp4':
            if (isset($metadata['quicktime']['moov']['subatoms'][0]['creation_time_unix'])) {
                $creation_date = (int) $metadata['quicktime']['moov']['subatoms'][0]['creation_time_unix'];
            }
            break;
    }
    return $creation_date;
}

WordPress Version: 5.7

/**
 * Parse creation date from media metadata.
 *
 * The getID3 library doesn't have a standard method for getting creation dates,
 * so the location of this data can vary based on the MIME type.
 *
 * @since 4.9.0
 *
 * @link https://github.com/JamesHeinrich/getID3/blob/master/structure.txt
 *
 * @param array $metadata The metadata returned by getID3::analyze().
 * @return int|false A UNIX timestamp for the media's creation date if available
 *                   or a boolean FALSE if a timestamp could not be determined.
 */
function wp_get_media_creation_timestamp($metadata)
{
    $creation_date = false;
    if (empty($metadata['fileformat'])) {
        return $creation_date;
    }
    switch ($metadata['fileformat']) {
        case 'asf':
            if (isset($metadata['asf']['file_properties_object']['creation_date_unix'])) {
                $creation_date = (int) $metadata['asf']['file_properties_object']['creation_date_unix'];
            }
            break;
        case 'matroska':
        case 'webm':
            if (isset($metadata['matroska']['comments']['creation_time']['0'])) {
                $creation_date = strtotime($metadata['matroska']['comments']['creation_time']['0']);
            } elseif (isset($metadata['matroska']['info']['0']['DateUTC_unix'])) {
                $creation_date = (int) $metadata['matroska']['info']['0']['DateUTC_unix'];
            }
            break;
        case 'quicktime':
        case 'mp4':
            if (isset($metadata['quicktime']['moov']['subatoms']['0']['creation_time_unix'])) {
                $creation_date = (int) $metadata['quicktime']['moov']['subatoms']['0']['creation_time_unix'];
            }
            break;
    }
    return $creation_date;
}

WordPress Version: 4.9

/**
 * Parse creation date from media metadata.
 *
 * The getID3 library doesn't have a standard method for getting creation dates,
 * so the location of this data can vary based on the MIME type.
 *
 * @since 4.9.0
 *
 * @link https://github.com/JamesHeinrich/getID3/blob/master/structure.txt
 *
 * @param array $metadata The metadata returned by getID3::analyze().
 * @return int|bool A UNIX timestamp for the media's creation date if available
 *                  or a boolean FALSE if a timestamp could not be determined.
 */
function wp_get_media_creation_timestamp($metadata)
{
    $creation_date = false;
    if (empty($metadata['fileformat'])) {
        return $creation_date;
    }
    switch ($metadata['fileformat']) {
        case 'asf':
            if (isset($metadata['asf']['file_properties_object']['creation_date_unix'])) {
                $creation_date = (int) $metadata['asf']['file_properties_object']['creation_date_unix'];
            }
            break;
        case 'matroska':
        case 'webm':
            if (isset($metadata['matroska']['comments']['creation_time']['0'])) {
                $creation_date = strtotime($metadata['matroska']['comments']['creation_time']['0']);
            } elseif (isset($metadata['matroska']['info']['0']['DateUTC_unix'])) {
                $creation_date = (int) $metadata['matroska']['info']['0']['DateUTC_unix'];
            }
            break;
        case 'quicktime':
        case 'mp4':
            if (isset($metadata['quicktime']['moov']['subatoms']['0']['creation_time_unix'])) {
                $creation_date = (int) $metadata['quicktime']['moov']['subatoms']['0']['creation_time_unix'];
            }
            break;
    }
    return $creation_date;
}