admin管理员组

文章数量:1389825

So, I am wondering if there is a way that I can make this:

February 28th, 2020

Just output NO month and NO year so just 28th (i.e. just the date)

What approach would you take?

I am applying this to a WordPress plugin called Pods.

The plugin allows for Custom Fields to be printed like this:

{@date}

And I know that you can run a PHP command from the functions file like this:

{@date,remove_month}

But figuring how to do that is tricky...any pointers?

So, I am wondering if there is a way that I can make this:

February 28th, 2020

Just output NO month and NO year so just 28th (i.e. just the date)

What approach would you take?

I am applying this to a WordPress plugin called Pods.

The plugin allows for Custom Fields to be printed like this:

{@date}

And I know that you can run a PHP command from the functions file like this:

{@date,remove_month}

But figuring how to do that is tricky...any pointers?

Share Improve this question asked Feb 28, 2020 at 13:20 HenryHenry 9831 gold badge8 silver badges31 bronze badges 2
  • I'd guess if it accepts anything it'd be a PHP date format string: I guess you want jS. But how the plugin works / how you do this will be specific to the plugin, so you'd have to ask them or read the code to figure it out yourself. – Rup Commented Feb 28, 2020 at 13:24
  • If the date is just a date in a string, then you don't need WordPress stuff to figure out the answer, it can be done entirely using raw PHP from php – Tom J Nowell Commented Feb 28, 2020 at 13:58
Add a comment  | 

1 Answer 1

Reset to default 1

You’ll need to write your OWN function that will take the post_date and return it reformatted to the style you’re looking for.

function my_date($input_date) {
   return date("S", strtotime($input_date));
}

And then you would call it within your Pods Template like

{@post_date, my_date}

All rights goes to Jim True. More infomations : https://pods.io/forums/topic/date-formatting-using-magic-tags/

本文标签: functionsRemove the month and year from a WordPress Date