{"id":631,"date":"2021-11-14T20:46:52","date_gmt":"2021-11-15T01:46:52","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=631"},"modified":"2024-02-08T08:44:37","modified_gmt":"2024-02-08T13:44:37","slug":"php-date-arithmetic","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/php-date-arithmetic\/","title":{"rendered":"PHP date arithmetic"},"content":{"rendered":"\n<p>strtotime() function can be used for date arithmetic. Following are some examples:<\/p>\n\n\n\n<p><strong>Get next date<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print date('Y-m-d', strtotime('+1 day', strtotime('2013-09-30')));\n<\/code><\/pre>\n\n\n\n<p>Prints<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2013-10-01\n<\/code><\/pre>\n\n\n\n<p><strong>Get previous month<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print date('Y-m-d', strtotime('-1 month', strtotime('2013-09-30')));\n<\/code><\/pre>\n\n\n\n<p>Prints<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2013-08-30\n<\/code><\/pre>\n\n\n\n<p><strong>Go back 5 years<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print date('Y-m-d', strtotime('-5 year', strtotime('2013-09-30')));\n<\/code><\/pre>\n\n\n\n<p>Prints<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2013-04-30<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>strtotime() function can be used for date arithmetic. Following are some examples: Get next date Prints Get previous month Prints Go back 5 years Prints<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-631","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=631"}],"version-history":[{"count":1,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/631\/revisions"}],"predecessor-version":[{"id":632,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/631\/revisions\/632"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}