Support » Plugin: Travelers' Map » Date might be in UTC

  • Resolved darro

    (@darro)


    Hi Camille,

    Firstly, thanks very much, I absolutely love your plugin. It does pretty much exactly what I wanted. The ability to add multiple points on a single post will be a fantastic addition.

    I have noticed a possible issue around the date. I had a post that was published on the 13/7/2020 at 3:30pm. I’m in AEST (GMT+10), on the map it showed the date as 14/7/2020. I changed the published date to the 13/7/2020 at 3:30AM (not PM) and the post now shows as 13/7 on the map. I think you may be pulling the UTC time and not the “local” time.

    I had a similar issue with the Room34 “On This Day” plugin.

    It’s an issue that might not show up much in Europe near UTC 0, but here at +10 it comes up a bit.

    Thanks
    Darro

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Camille V

    (@socrapop)

    Dear Darro,
    Thank you for this report, date format is indeed difficult.
    Let’s try to debug that:

    First thing to look at, I use get_the_date() in the shortcode to get the post date from WordPress. This function takes the language set in the WordPress administration panel. So maybe try to change it to EN_AU Australia if it’s not already.

    The second thing is in the JavaScript, I use a function to translate the date to the local of the user.

    let postDate = new Date(postdatas.date);
      postDate = postDate.toLocaleDateString(undefined, {
        year: "numeric",
        month: "long",
        day: "numeric",
      });

    So I will have a look if the first solution doesn’t work 😉
    Have a nice day

    • This reply was modified 8 months, 2 weeks ago by Camille V.
    Thread Starter darro

    (@darro)

    Hey, wow, thanks for the quick response.

    The Site Language is “English (Australian)”
    The timezone is “Sydney”

    So it is currently reporting “Universal time is 2021-05-12 06:46:17. Local time is 2021-05-12 16:46:17.”

    I’m using a custom Date format of “l, F j, Y” to get the day of the week in the post.

    Time is in the default “g:i a” format.

    Does this help?

    Thank
    Darro

    • This reply was modified 8 months, 2 weeks ago by darro.
    Plugin Author Camille V

    (@socrapop)

    Okay so, I was sending the date to javascript as a Unix date format, which is based on UTC timezone. So your date set in UTC+10 was converted to UTC without substracting 10 hours.
    Then the javascript was converting this UNIX date (thinking it was in UTC) to a readable date format at your local machine timezone, so adding 10 hours.

    I changed get_the_date to return the date as a readable date, javascript is smart enough to read it and transcribe it to the local format, without changing timezone.
    So the date shown is now the same as in your administration.

    The update V1.12 is coming soon, I’m adding two or three other things with it.

    Have a nice day,
    Camille

    • This reply was modified 8 months, 1 week ago by Camille V.
    Thread Starter darro

    (@darro)

    Thanks you very much.

    No rush, whenever you get the chance.

    I’m really looking forward to the multiple markers in V2!

    Cheers
    Darro

    Plugin Author Camille V

    (@socrapop)

    Dear Darro,

    V1.12.0 is up in a few minutes, with the fix for this issue 😉
    Please let me know if something is still not working.

    Have a nice day,
    Camille

    Thread Starter darro

    (@darro)

    Hi Camille

    Yep, that’s done the trick. Perfect.

    Thanks very much for such as quick response.

    Cheers
    Darro

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Date might be in UTC’ is closed to new replies.