functions - Remove the month and year from a WordPress Date?

So, I am wondering if there is a way that I can make this:February 28th, 2020Just output NO month and NO year so just 28

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/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744707549a4589145.html

相关推荐

  • functions - Remove the month and year from a WordPress Date?

    So, I am wondering if there is a way that I can make this:February 28th, 2020Just output NO month and NO year so just 28

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信