incorrect time after importing

Pending

Import WP Pro Updated 1 week ago 2 Replies

Jack asked 1 week ago on April 15, 2025 at 9:30 am

I am importing data via an xml file, in the fomat of the below:

<date_time_iso format=”ISO 8601″ zone=”IST”>2025-05-10T19:30:00+01:00</date_time_iso>

When pulled through is it displaying as:

Saturday May 10th, 6:30 pm

It is an hour behind, wp timezone is set to london curently

display and return format is set to: l F jS, g:i a

do you know how I can fix this and dispaly the correct time of 7.30pm?

 

J

James replied Support Agent

1 week ago on April 15, 2025 at 3:32 pm

Hi Jack,

For wordpress to understand the timezone and convert it from IST to your local timezone you will need to write a custom funciton similar to the following that reads in the timestamp as IST and outputs it in the wp timezone, i have also attached this function in a custom plugin.

function convert_date_from_ist($input)
{
    $date_test = date_create_from_format(DATE_ATOM, $input, new DateTimeZone('IST'));
    if (!$date_test) {
        return '';
    }
    $date_test->setTimezone(wp_timezone());
    return $date_test->format('Y-m-d H:i:s');
}

To use this function, once the code is on your website you can instead take the importer selector:

{/date_time_iso}

and use the custom function instead:

[convert_date_from_ist("{/date_time_iso}")]

James

J

James replied Support Agent

1 week ago on April 15, 2025 at 3:33 pm