{"id":438,"date":"2017-07-12T11:56:54","date_gmt":"2017-07-12T11:56:54","guid":{"rendered":"https:\/\/ampforwp.com\/tutorials\/?p=438"},"modified":"2020-07-14T11:22:27","modified_gmt":"2020-07-14T11:22:27","slug":"change-date-in-amp","status":"publish","type":"ht_kb","link":"https:\/\/ampforwp.com\/tutorials\/article\/change-date-in-amp\/","title":{"rendered":"How to Modify Date or Change Date Format in AMP"},"content":{"rendered":"\n<p><strong>In this tutorial we will show you two ways to Modify or Change Date Format in AMP<\/strong><\/p>\n\n\n\n<p>1 &#8211; <a href=\"https:\/\/ampforwp.com\/tutorials\/article\/change-date-in-amp\/#1-by-using-an-option-in-amp-settings\">By using an Option in AMP settings<\/a><\/p>\n\n\n\n<p>2 &#8211; <a href=\"https:\/\/ampforwp.com\/tutorials\/article\/change-date-in-amp\/#2-by-using-code\">By using Code<\/a><\/p>\n\n\n\n<h3>1 &#8211; By using an Option in AMP settings<\/h3>\n\n\n\n<ul><li>You will find this option in this <strong>WordPress Dashboard<\/strong> -> Navigate to <strong>AMP option Pane<\/strong>l -> <strong>Date -> <\/strong>In this <strong>&#8220;Show Date As<\/strong>&#8221; option you need to select the &#8220;<strong>Modified Date<\/strong>&#8221; option.<\/li><\/ul>\n\n\n\n<ul><li><strong>Date Format: <\/strong>Once you select \u201c<strong>Date Format<\/strong>\u201d option two options will be displayed &#8220;<strong>Ago<\/strong>&#8221; and &#8220;<strong>Traditional view<\/strong>&#8221; as per your requirement you can enable those options and then click on the \u201c<strong>Save Changes<\/strong>\u201d button.<\/li><\/ul>\n\n\n\n<p><strong>Ago:<\/strong><\/p>\n\n\n\n<ul><li><strong>Ago:<\/strong> In Date format, Select the Date Format of Posts. <\/li><li><strong>Text for the Date Format:<\/strong>  In this file, you need to enter Date Format for example &#8211; English &#8211; % days ago, Spain &#8211; ago % days <\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"505\" src=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2020\/07\/16-1-1024x505.png\" alt=\"\" class=\"wp-image-17552\" srcset=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2020\/07\/16-1-1024x505.png 1024w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2020\/07\/16-1-300x148.png 300w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2020\/07\/16-1-768x379.png 768w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2020\/07\/16-1-50x25.png 50w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2020\/07\/16-1-60x30.png 60w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2020\/07\/16-1-100x49.png 100w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2020\/07\/16-1.png 1226w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p> <strong>Traditional view<\/strong> :<\/p>\n\n\n\n<ul><li><strong>Traditional view<\/strong>: In Date format select the Date Format of Posts <\/li><li><strong>Time<\/strong>:\u00a0By using this option you can Enable or Disable Time In Posts <\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/4.png\"><img decoding=\"async\" loading=\"lazy\" width=\"908\" height=\"329\" src=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/4.png\" alt=\"\" class=\"wp-image-14667\" srcset=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/4.png 908w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/4-300x109.png 300w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/4-768x278.png 768w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/4-50x18.png 50w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/4-60x22.png 60w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/4-100x36.png 100w\" sizes=\"(max-width: 908px) 100vw, 908px\" \/><\/a><\/figure>\n\n\n\n<ul><li>How to Change Date and Time Format in WordPress for this follow this tutorial <a href=\"https:\/\/www.wpbeginner.com\/beginners-guide\/how-to-change-date-and-time-format-in-wordpress\/#targetText=Date%20and%20Time%20Settings%20in%20WordPress&amp;targetText=You%20can%20modify%20your%20format,the%20date%20and%20time%20formats.\">Click Here<\/a>. <\/li><\/ul>\n\n\n\n<h4><strong>The Output Of Modify Date in AMP<\/strong><\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/11.png\"><img decoding=\"async\" loading=\"lazy\" width=\"540\" height=\"540\" src=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/11.png\" alt=\"\" class=\"wp-image-14716\" srcset=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/11.png 540w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/11-150x150.png 150w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/11-300x300.png 300w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/11-50x50.png 50w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/11-60x60.png 60w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/11-100x100.png 100w\" sizes=\"(max-width: 540px) 100vw, 540px\" \/><\/a><\/figure><\/div>\n\n\n\n<h3>2 &#8211; By using Code<\/h3>\n\n\n\n<h4>A) &#8211; Modifying via Filter<\/h4>\n\n\n\n<ul><li>You need to add the following filter code into your theme&#8217;s functions.php&nbsp;file at the end of the code or <a href=\"https:\/\/ampforwp.com\/tutorials\/article\/create-a-custom-amp-theme-for-wordpress\/\" target=\"_blank\" rel=\"noreferrer noopener\">create a custom plugin<\/a> and add the following code.<\/li><\/ul>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text\/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;PHP&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;php&quot;}\">add_filter('ampforwp_modify_post_date','ampforwp_modify_date_index');\nfunction ampforwp_modify_date_index($date) {\n    $date = get_the_date();    \n    return $date;\n}<\/pre><\/div>\n\n\n\n<ul><li>By doing the above-mentioned changes you&#8217;ve changed the date format, or you can get the desired format by playing with the <code>ampforwp_modify_date_index()<\/code> function code.<\/li><\/ul>\n\n\n\n<h4>B) &#8211; Using amp_date() function<\/h4>\n\n\n\n<ul><li>If you have created a custom template and used the function <code>amp_date() <\/code> and want to change the date, then you can pass an array like shown below.<\/li><\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">amp_date(array('custom_format'=&gt;'l - d, F, Y') );<\/pre>\n\n\n\n<ul><li>We use <code>Date()<\/code> 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 <a href=\"http:\/\/php.net\/manual\/en\/function.date.php#refsect1-function.date-parameters\" target=\"_blank\" rel=\"noreferrer noopener\"> date types here.<\/a><\/li><\/ul>\n\n\n\n<h4>The Output of the&nbsp;Using amp_date() function<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" loading=\"lazy\" width=\"1100\" height=\"677\" src=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/change-date-in-amp.png\" alt=\"How to change date in amp wordpress\" class=\"wp-image-4388\" srcset=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/change-date-in-amp.png 1100w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/change-date-in-amp-300x185.png 300w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/change-date-in-amp-768x473.png 768w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/change-date-in-amp-1024x630.png 1024w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/change-date-in-amp-50x31.png 50w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/change-date-in-amp-60x37.png 60w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2017\/07\/change-date-in-amp-100x62.png 100w\" sizes=\"(max-width: 1100px) 100vw, 1100px\" \/><\/figure><\/div>\n\n\n\n<p><strong>That\u2019s it for this tutorial!<\/strong><\/p>\n\n\n\n<p>We hope it helped you. If you have any feedback or questions, then please share them in the comments section below.<\/p>\n<div id=\"div-1\" class=\"hkb-feedback\">\n\t\t\t<strong class=\"ht-mobile-exit__title\">Ask your Questions Directly!<\/strong><br>\n\t\t\t<div class=\"hkb_widget_exit__content\" style=\"font-size: 14px;\">If you can't find the solutions in this article, then just ask us in the comments and we will answer it for you!<\/div>\n\t\t\t<a href=\"https:\/\/ampforwp.com\/support\/#contact\" id=\"button\" target=\"_blank\" rel=\"noopener noreferrer\"><button>Yes, I have a Question<\/button><\/a>\n\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>In this tutorial we will show you two ways to Modify or Change Date Format in AMP 1 &#8211; By using an Option in AMP settings 2 &#8211; By using Code 1 &#8211; By using an Option in AMP settings You will find this option in this WordPress Dashboard ->&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"open","ping_status":"open","template":"","format":"standard","meta":[],"ht-kb-category":[34],"ht-kb-tag":[],"_links":{"self":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/438"}],"collection":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/comments?post=438"}],"version-history":[{"count":48,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/438\/revisions"}],"predecessor-version":[{"id":17555,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/438\/revisions\/17555"}],"wp:attachment":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/media?parent=438"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb-category?post=438"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb-tag?post=438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}