{"id":143,"date":"2012-02-04T02:27:10","date_gmt":"2012-02-04T02:27:10","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=143"},"modified":"2012-02-04T02:27:10","modified_gmt":"2012-02-04T02:27:10","slug":"php-add-date-months-years-to-current-date","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/php-add-date-months-years-to-current-date\/","title":{"rendered":"PHP: Add Date, Months, Years to current date"},"content":{"rendered":"<p>Did you ever want to add date, months or years to current date in PHP but never figured out how to? Well, this little snippet can come in handy.<!--more--><\/p>\n<p><strong>PHP Add Date, Months, Years to current date<\/strong><\/p>\n<pre class=\"lang:php decode:true\">\/\/For simplicity, I have selected American date format as I am used to it.\n\/\/You may select any format that your application uses, such as date(\"d-m-Y\")\n\/\/or date(\"Y-m-d\"), etc.\n\n$current_date = date(\"m-d-Y\");\necho \"Current Date: \".$current_date.\"&lt;br \/&gt;\";\n\n\/\/Add 1 Day to current date i.e. today\n$add_day = strtotime(date(\"m-d-Y\", strtotime($current_date)) . \"+1 day\");\necho \"After adding 1 Day: \".date('m-d-y', $add_day).\"&lt;br \/&gt;\";\n\/\/Add 10 Days to current date\n$add_days = strtotime(date(\"m-d-Y\", strtotime($current_date)) . \"+10 day\");\necho \"After adding 10 Days: \".date('m-d-Y', $add_days).\"&lt;br \/&gt;\";\n\n\/\/Add 1 Month to current date\n$add_month = strtotime(date(\"m-d-Y\", strtotime($current_date)) . \"+1 month\");\necho \"After adding 1 Month: \".date('m-d-Y', $add_month).\"&lt;br \/&gt;\";\n\/\/Add 10 Months to current date\n$add_months = strtotime(date(\"m-d-Y\", strtotime($current_date)) . \"+10 month\");\necho \"After adding 10 Months: \".date('m-d-Y', $add_months).\"&lt;br \/&gt;\";\n\n\/\/Add 1 Year to current date\n$add_year = strtotime(date(\"m-d-Y\", strtotime($current_date)) . \"+1 year\");\necho \"After adding 1 Year: \".date('m-d-Y', $add_year).\"&lt;br \/&gt;\";\n\/\/Add 10 Years to current date\n$add_years = strtotime(date(\"m-d-Y\", strtotime($current_date)) . \"+10 year\");\necho \"After adding 10 Years: \".date('m-d-Y', $add_years).\"&lt;br \/&gt;\";\n\n\/\/Results:\nCurrent Date: 02-04-2012\nAfter adding 1 Day: 02-05-12\nAfter adding 10 Days: 02-14-2012\nAfter adding 1 Month: 03-04-2012\nAfter adding 10 Months: 12-04-2012\nAfter adding 1 Year: 02-04-2013\nAfter adding 10 Years: 02-04-2022<\/pre>\n<p><strong>That&#8217;s it!<\/strong><\/p>\n<p>I am sure that there are other ways to do this. Do you know of any other ways to <strong>add date, month and year using PHP<\/strong>? If yes, we would love to hear from you. Please leave your comments below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Did you ever want to add date, months or years to current date in PHP but never figured out how to? Well, this little snippet can come in handy.<\/p>\n","protected":false},"author":1,"featured_media":141,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10,7,6,13],"tags":[32,33],"class_list":["post-143","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-tips-and-tricks","category-php","category-snippets","category-tips-and-tricks","tag-php-snippets","tag-php-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-2j","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=143"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/143\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}