wp_exif_date2ts() WordPress Function

The wp_exif_date2ts() function converts an EXIF date into a timestamp. This is useful for sorting images based on when they were taken.

wp_exif_date2ts( string $str ) #

Convert the exif date format to a unix timestamp.


Parameters

$str

(string)(Required)A date string expected to be in Exif format (Y:m:d H:i:s).


Top ↑

Return

(int|false) The unix timestamp, or false on failure.


Top ↑

Source

File: wp-admin/includes/image.php

function wp_exif_date2ts( $str ) {
	list( $date, $time ) = explode( ' ', trim( $str ) );
	list( $y, $m, $d )   = explode( ':', $date );

	return strtotime( "{$y}-{$m}-{$d} {$time}" );
}


Top ↑

Changelog

Changelog
VersionDescription
2.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.