Some WordPress fields require dates in a specific format. You can change a date with Import WP custom methods: a PHP function in your theme’s functions.php file or a plugin that runs before the value is imported. See Using code snippets in WordPress for how to add the snippet.
From Import WP 2.15, custom methods in Template Fields must use the iwp: prefix, for example [iwp:iwpe01_format_date("...")]. That prefix stops the mapping from being treated as a WordPress shortcode or Gutenberg block. Saved importers that used [function_name(...)] are rewritten to [iwp:function_name(...)] when you update. The PHP function name is unchanged; only the mapping syntax changes.
Add the following code snippet to your website:
function iwpe01_format_date($input = '', $output_format = 'd/m/Y', $input_format = 'date')
{
switch ($input_format) {
case 'date':
$time = strtotime($input);
break;
case 'timestamp':
default:
$time = $input;
break;
}
if (intval($time) == 0) {
return '';
}
return date($output_format, $time);
}
Then when editing your importer on the “Template Fields” step, use the custom method with the iwp: prefix. Each argument inside "" can be replaced with data from your importer, e.g. CSV {0} or XML {/date}.
Example returning the default date format:
[iwp:iwpe01_format_date("2021-06-04T18:59:59.999Z")]
Returns: 04/06/2021
Example changing the returned date format:
[iwp:iwpe01_format_date("2021-06-04T18:59:59.999Z", "d-m-Y")]
Returns: 04-06-2021
Example converting a timestamp into a date format:
[iwp:iwpe01_format_date("1622833199", "d-m-Y", "timestamp")]
Returns: 04-06-2021
Updated 2026-09-21