• Resolved terryarthur

    (@terryarthur)


    Hello,

    Thank you for a great plugin. I am having a minor issue that I can’t seem to solve.

    I am using a custom field to import the date. I have specified the html correctly because dates do import but the month and day are transposed so that some dates have a month greater than 12 and end up as 1/1/1970 and all other dates have the day and month swapped. I have tried changing the date format in WordPress prior to import but no luck.

    The field I am importing is formatted like this <li class=”ContentPublishDate tplvar-content-publishdate”>1-6-2016 it is month-day-Year format. But when this date imports I get 6-1-2016 even though my date format is set to n-j-Y which matches the date in the import.

    Any help would be appreciated.

    Thanks again for a great plugin,

    Terry Arthur

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter terryarthur

    (@terryarthur)

    So I figured this out. Turns out there is some disambiguation by PHP I wasn’t aware of.

    STRTOTIME Note:
    Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed. If, however, the year is given in a two digit format and the separator is a dash (-, the date string is parsed as y-m-d.
    To avoid potential ambiguity, it’s best to use ISO 8601 (YYYY-MM-DD) dates or DateTime::createFromFormat() when possible.

    The site I was importing from was displaying the dates using dashes and not slashes and STRTOTIME was assuming they were European but the site is in the US so it was necessary to change the site I was importing from to use / instead of – and then reimport all the pages. After that everything went great for 1,398 posts, images, attachments, tags everything.

    This is a fantastic plugin and the only issue was with something I didn’t know about PHP.

    Thread Starter terryarthur

    (@terryarthur)

    Forgot to mark this solved.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘month and day transposed on import’ is closed to new replies.