• I have following testbed:

    <p>[field date]</p>
    <p>[format date=Y-m-d][field date][/format]</p>

    The output is:

    8. Februar 2016 (The real date of the published article, german formatted)
    2016-05-13 (The actual date?)

    It seems that formatting [field date] results in not showing the date of publishing the article anymore but showing the actual date.

    Regards,
    Besim

    https://ww.wp.xz.cn/plugins/custom-content-shortcode/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Eliot Akira

    (@miyarakira)

    Hello, thank you for the note.

    I tested this and it’s working on my end – both dates are showing the published date. I directly copied and ran your code, so that’s strange that it’s behaving differently in your case. I wonder what could be the difference.. Is the code in the normal post editor or in a visual builder of some kind?

    Thread Starter Besim Karadeniz

    (@besimk)

    Hi Eliot,

    This is in the normal post editor of WordPress. Let me give you some details of my installation:

    – WordPress 4.5.2 Multiuser with official german language package
    – Using your plugin in version 3.5.3, not enabled for all instances
    – Activated plugin ACF Pro

    Can I do something about debugging for you? My setup is for testing purposes here.

    Plugin Author Eliot Akira

    (@miyarakira)

    Maybe [format] is having difficulty understanding the given date “8. Februar 2016” since it’s already formatted and has a word in it.

    There’s a parameter for [field] that does date format too. Could you try the following?

    [field date date_format=Y-m-d]

    If this works – and it probably will – then I recommend using this syntax, because it gets the date more directly instead of pre-formatted. I’ll have to make a note about this for [format date], that it accepts a limited range of input. I think it makes sense that it cannot understand dates with words in it. (Or maybe it knows only English..!?)

    As another test, could you try this too?

    [format date=Y-m-d in=timestamp][field date date_format=U][/format]

    It’s kind of silly to write it that way, but I imagine that works, and if so, that shows the limitation of [format].

    Thread Starter Besim Karadeniz

    (@besimk)

    Hi Eliot,

    pleased to help you with some debugging. πŸ™‚

    [format date=Y-m-d in=timestamp][field date date_format=U][/format]

    and

    [field date date_format=Y-m-d]

    are resulting “2016-02-08”. This is the publishing date of my test article. So far so good.

    But I have some special thing: I’m asking for the weekday (in PHP dateformat “l”). And there I have two results:

    [field date date_format=Y-m-d]

    is resulting “Montag” (Monday in german), the right weekday of 2016-02-08. Perfect. But:

    [format date=Y-m-d in=timestamp][field date date_format=U][/format]

    is resulting “1970-01-01”.

    It seems for me that you are using the given date with the local date formatted from the WordPress translation. Would it be not better to use the internal time stamp of WordPress? That should work everywhere on the planet. πŸ™‚

    Plugin Author Eliot Akira

    (@miyarakira)

    For the last two examples, you probably mean:

    [field date date_format=l]

    and

    [format date=l in=timestamp][field date date_format=U][/format]

    I tested these, and they’re working correctly on my end. I wonder what is different in your case?

    Last year, I spent a considerable amount of time correcting the date format and comparisons, because the plugin used both WordPress and native PHP date/time functions (and how they handle timezones). So, I believe that part is solid.

    [format] is a fairly new feature, so, if there is any issue, it’s probably there.

    Thread Starter Besim Karadeniz

    (@besimk)

    Hi Eliot,

    sorry to bother you with formatting things again but I have a significant difference here which I cannot handle. Formatting with the field-argument works nice but formatting with pass makes me clueless in a point.

    The code:

    [pass field=date]
    {FIELD}
    [/pass]

    shows in my testbed the date of publishing of the article in normal local formatting.

    The code:

    [pass field=date date_format=c]
    {FIELD}
    [/pass]

    should show the date/time of the publishing date of the article too in another format. But it shows the actual date/time as 2016-05-20T16:25:36+00:00. Right formatted but that is the actual time and not the time of the article publishing.

    How can I get the publishing date into a pass-argument? Also the way through the format-argument seems not working.

    Besim

    Plugin Author Eliot Akira

    (@miyarakira)

    Hi Besim,

    There was an undocumented bit of code doing some date formatting for [pass] but it was not behaving the same as [field]. In the newest update, I improved the date_format parameter for [pass] so it should work as expected now.

    Thread Starter Besim Karadeniz

    (@besimk)

    Nice, it’s working. Thanks

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Bug in formatting [field date]’ is closed to new replies.