Clicky

  1. Home
  2. How To
  3. How to Modify Date or Change Date Format in AMP

How to Modify Date or Change Date Format in AMP

In this tutorial we will show you two ways to Modify or Change Date Format in AMP

1 – By using an Option in AMP settings

2 – By using Code

1 – By using an Option in AMP settings

  • You will find this option in this WordPress Dashboard -> Navigate to AMP option Panel -> Date -> In this “Show Date As” option you need to select “Modified Date” option.

  • Date Format: Once you select “Date Format” option two option will be displayed “Ago“and “Traditional view” as per your requirement you can enable those options and then click on the “Save changes” button.
  • In Date format once you select “Ago” option “Text for the Date Format” will be display 
  • In Date format once you select “Traditional view” option “Time” will be display 

  • Time: By uisng this option you can Enable or Disable Time In Posts
  • How to Change Date and Time Format in WordPress for this follow this tutorial Click Here.

The Output Of Modify Date in AMP

2 – By using Code

A) – Modifying via Filter

  • You need to add the following filter code into your theme’s functions.php file at the end of the code or create a custom plugin and add the following code.
  • By doing the above-mentioned changes you’ve changed the date format, or you can get the desired format by playing with the ampforwp_modify_date_index() function code.

B) – Using amp_date() function

  • If you have created a custom template and used the function amp_date() and want to change the date, then you can pass an array like shown below.

Example:

  • We use Date() function to show the date and all the compatible date formats are supported by amp_date() function. Here is the list of all the available date types here.

The Output of the Using amp_date() function

How to change date in amp wordpress

 

That’s it for this tutorial!

We hope it helped you. If you have any feedback or questions, then please share them in the comments section below.

Ask your Questions Directly!
If you can't find the solutions in this article, then just ask us in the comments and we will answer it for you!
Updated on October 22, 2019

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support

Comments

  1. I do not want to show sate on homepage in the free version in the third design template. I want to completely remove date. The single posts dont show date in meta but the homepage shows like 1 year ago, 11 months ago. Please guide me how to remove it.

  2. Hi there,

    I have inserted this code into functions.php but for Design 1 it still shows human readable time. I looked into the code for design 1 and it seems hardcoded. Is there any way around this? Thanks!

Leave a Comment