• Resolved LeonLuc

    (@gameleon)


    It seems there is an issue with the timezone. The WordPress blog I am importing to has its timezone set to Los Angeles time. But all imported posts timestamps seem to be British times.

    For example: Both the Blogger blog and WordPress blog involved in the migration are set to Los Angeles time (UTC-7 during summer time). If a post that was posted at 8:00am Los Angeles time on Blogger get migrated, it ends up in WordPress with a timestamp of 5:00pm (or 17:00), which is the British time (UTC+1 during summer time), interpreted as Los Angeles time

    This seems to be related to this bit of code when the importer creates the WordPress post:

    $insert_post = array(
    				'post_type' => 'post',
    				'post_date' => $item->published,
    				'post_content' => '',
    				'post_title' => $item->title,
    				'post_status' => 'publish',
    				'ping_status' => 'closed',
    				'post_name' => $item->slug,
    				'tags_input' => property_exists($item, 'labels') ? $item->labels : '',
    			);

    The post_date property requires a timestamp in the timezone of the WordPress blog, but the $item->published property seems to always be British time, causing the time mistmatch in the blog.

    If the $item->published timestamp retrieved from the api can be guaranteed to be UTC/GMT instead it could be easily solved using the GMT property 'post_date_gmt' => $item->published. Then WordPress would handle the conversion for the local blog timezone based timestamps.

    I don’t know how this could be easily solved for British time though (since that only matches up with UTC/GMT during winter time).

    • This topic was modified 3 years, 5 months ago by LeonLuc. Reason: Added workaround I've used
    • This topic was modified 3 years, 5 months ago by LeonLuc. Reason: Added info on get_date_from_gmt
    • This topic was modified 3 years, 5 months ago by LeonLuc.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author pipdig

    (@pipdig)

    Hi @gameleon,

    I think the issue you’re hitting here is because WordPress defaults to UTC timezone when installed. Before starting the import, it is best to set the timezone to the same thing as Blogger.

    For example, if the timezone in Blogger is Los Angeles – https://imgur.com/a/0N333d4 – you would first set the time to Los Angeles in WordPress here – https://imgur.com/a/gjfrrEs

    Thread Starter LeonLuc

    (@gameleon)

    Both Blogger and WordPress were set to Los Angeles time before the first import was started.

    I can reproduce the issue as follows:

    • I have a Blogger and WordPress blog both configured at Los Angeles time
    • I create a post on Blogger at 8:00am Los Angeles time. (keep in mind the new Blogger editor shows the local time of the current machine for some reason, not the actual blog time)
    • I confirm the atom feed returns the time with the proper time and timezone suffix: <published>2021-10-24T08:00:00.000-07:00</published>
    • When importing this post into WordPress using the plugin I can see in the logs that the api.bloggerimporter.com endpoint returns the time in British time (BST timezone) for reason: published: "2021-10-24 16:00:00".
    • The plugin then inserts this British time into the post_date property of wp_insert_post.
    • The post_date property expects a local time value according to the WordPress timezone, so WordPress interprets this as 16:00/4:00pm Los Angeles time, causing the time of the post to be off by 8 hours from the expected time

    This happens with any non-British timezone. Los Angeles is just an example.

    The way to fix this would be to make sure the time returned by api.bloggerimporter.com is UTC rather than BST and then insert it in the post_date_gmt property instead (WordPress will then automatically handle the conversion from UTC back to the WordPress timezone).

    • This reply was modified 3 years, 4 months ago by LeonLuc.
    • This reply was modified 3 years, 4 months ago by LeonLuc.
    • This reply was modified 3 years, 4 months ago by LeonLuc.
    Plugin Author pipdig

    (@pipdig)

    Hi @gameleon, apologies for the delay in getting back to you.

    I am not able to replicate this issue. Are you sure that the timezone is set to Los Angeles in Blogger? Please could you send a screenshot of that from the Blogger dashboard?

    Plugin Author pipdig

    (@pipdig)

    Hi @gameleon,

    I’ve just spotted a possible issue with this which is the likely cause. Blogger seems to return a different date pattern for posts published recently. So they must have changed the date/time formatting for new posts after a certain date …which is strange.

    We’ll look further into it today and get back to you to confirm. It should be a quick fix to handle the new date/time format they’re presenting in the API.

    Plugin Author pipdig

    (@pipdig)

    Hi @gameleon,

    We’ve just pushed version 3.1.1 which will fix this. There were some really weird dates being returned by the Blogger API relating to UTC, daylight saving, and how long ago a post was published on Blogger. We’ve worked around that by converting all dates to UTC and setting the publish date via post_date_gmt, as you mentioned.

    Please go ahead and update and let me know if you run into any issues. I tried a test import and can confirm the dates are coming through correct on a variety of different timezones.

    Thread Starter LeonLuc

    (@gameleon)

    Apologies for the late reaction as well (I got no notifications for this thread for some reason).

    I can confirm the timezone handling works perfectly now!

    Plugin Author pipdig

    (@pipdig)

    No problem, glad to hear the update has fixed the issue for you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Timezone seems to be off’ is closed to new replies.