I don’t think you need to do that, it’s already there (if I understand the question correctly):
-
In the WXR file we get a timestamp like:
that’s generated with:
<?php the_generator( 'export' ); ?>
that calls
get_the_generator()
where the export case is:$gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';
It’s possible to modify it or append to it via the
get_the_generator_export
filter. -
Additionally the timestamp is added to the xml document with:
<channel> ... <pubDate><?php echo date( 'D, d M Y H:i:s +0000' ); ?></pubDate>
-
The generated export filename also contains a datestamp:
$wp_filename = $sitename . 'wordpress.' . $date . '.xml';
Update
To modify the exported filename, one can use this filter:
/**
* Filters the export filename.
*
* @since 4.4.0
*
* @param string $wp_filename The name of the file for download.
* @param string $sitename The site name.
* @param string $date Today's date, formatted.
*/
$filename = apply_filters( 'export_wp_filename', $wp_filename, $sitename, $date );
Example:
Here we add the \TH-i-s
part to the filename:
add_filter( 'export_wp_filename', function( $wp_filename, $sitename, $date )
{
return sprintf(
'%swordpress.%s.xml',
$sitename,
date( 'Y-m-d\TH-i-s' )
);
}, 10, 3 );
This will generate a filename like:
sitename.wordpress.2016-10-22T19-26-07.xml
This will avoid a possible confusing download series like this one:
sitename.wordpress.2016-10-22.xml
sitename.wordpress.2016-10-22 (1).xml
sitename.wordpress.2016-10-22 (2).xml
sitename.wordpress.2016-10-22 (3).xml
...
Hope you can adjust this to your needs!