Here is one you can use. This will output ‘April 2018’
You will need to add this to your wp all import function editor.
function formatDate($str) {
$yr = preg_replace('#\/[^/]*$#', '', $str);
$month = preg_replace('/^.*\/\s*/', '', $str);
$mth = 'Invalid Month';
if($month >= 1 && $month <= 12){
$mth = date("F", strtotime("2001-" . $month . "-01"));
}
return $mth.' '.$yr;
}
Call it as such.
[formatDate({yourXmlDate[1]})]
Hi @chemistrap1
You can do this with a custom PHP function: http://www.wpallimport.com/documentation/developers/execute-php/ (as mentioned by @duceduc above).
It looks like this snippet above should work, and here’s another example snippet in case it helps:
function changeDate( $date ) {
if ( $dateObj = DateTime::createFromFormat( "Y/m", $date ) ) {
return $dateObj->format( "F Y" );
} else {
return $date;
}
}
Thank you for help. I guess your snipper code more logical other but thanks anyway to guys.
@duceduc your code was work but only translate problem occured. How can i handle that?
Thank you.
@duceduc thank you so much again.
I handle localization with i18n
if change your code like that
function formatDate($str) {
$yr = preg_replace('#\/[^/]*$#', '', $str);
$month = preg_replace('/^.*\/\s*/', '', $str);
$mth = 'Invalid Month';
if($month >= 1 && $month <= 12){
$mth = date_i18n("F", strtotime("2001-" . $month . "-01"));
}
return $mth.' '.$yr;
}
it worked like what exactly want.
I’m marking this as resolved, but feel free to continue the custom code discussion in this thread if you’d like.