Title: wp_get_media_creation_timestamp
Published: November 20, 2017
Last modified: August 20, 2026

---

# wp_get_media_creation_timestamp( array $metadata ): int|false

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_get_media_creation_timestamp/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_get_media_creation_timestamp/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_get_media_creation_timestamp/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_get_media_creation_timestamp/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_get_media_creation_timestamp/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_get_media_creation_timestamp/?output_format=md#changelog)

Parses creation date from media metadata.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_get_media_creation_timestamp/?output_format=md#description)󠁿

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.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_get_media_creation_timestamp/?output_format=md#parameters)󠁿

 `$metadata`arrayrequired

The metadata returned by getID3::analyze().

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_get_media_creation_timestamp/?output_format=md#return)󠁿

 int|false A Unix timestamp for the media’s creation date if available or a boolean
false if the timestamp could not be determined.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_get_media_creation_timestamp/?output_format=md#source)󠁿

    ```php
    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;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/media.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-admin/includes/media.php#L3803)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/includes/media.php#L3803-L3835)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_get_media_creation_timestamp/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_read_video_metadata()](https://developer.wordpress.org/reference/functions/wp_read_video_metadata/)`wp-admin/includes/media.php` |

Retrieves metadata from a video file’s ID3 tags.

  | 
| [wp_read_audio_metadata()](https://developer.wordpress.org/reference/functions/wp_read_audio_metadata/)`wp-admin/includes/media.php` |

Retrieves metadata from an audio file’s ID3 tags.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_get_media_creation_timestamp/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.9.0](https://developer.wordpress.org/reference/since/4.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_media_creation_timestamp%2F)
before being able to contribute a note or feedback.