{"id":80,"date":"2014-05-13T10:49:53","date_gmt":"2014-05-13T04:49:53","guid":{"rendered":"http:\/\/ronniee.net\/?p=80"},"modified":"2014-05-13T10:49:53","modified_gmt":"2014-05-13T04:49:53","slug":"date-difference-for-php-5-2","status":"publish","type":"post","link":"https:\/\/ronniee.net\/?p=80","title":{"rendered":"Date Difference for PHP 5.2"},"content":{"rendered":"\n<pre class=\"lang:php decode:true \" >&lt;?php \r\ndate_default_timezone_set('UTC');\r\nfunction custom_date_diff($date1, $date2) { \r\n\t$current = $date1; \r\n\t$datetime2 = date_create($date2); \r\n\t$count = 0; \r\n\twhile(date_create($current) &lt; $datetime2){ \r\n\t$current = gmdate(\"Y-m-d\", strtotime(\"+1 day\", strtotime($current))); \r\n\t$count++; \r\n\t} \r\n\treturn $count; \r\n} \r\n\r\necho (custom_date_diff('2014-05-10 00:00:00', '2014-05-15 00:00:00').\" days left\");\r\n?&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&lt;?php date_default_timezone_set(&#8216;UTC&#8217;); function custom_date_diff($date1, $date2) { $current = $date1; $datetime2 = date_create($date2); $count = 0; while(date_create($current) &lt; $datetime2){ $current = gmdate(&#8220;Y-m-d&#8221;, strtotime(&#8220;+1 day&#8221;, strtotime($current))); $count++; } return $count; } echo (custom_date_diff(&#8216;2014-05-10 00:00:00&#8217;, &#8216;2014-05-15 00:00:00&#8217;).&#8221; days left&#8221;); ?&gt;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-80","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/ronniee.net\/index.php?rest_route=\/wp\/v2\/posts\/80","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ronniee.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ronniee.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ronniee.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ronniee.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=80"}],"version-history":[{"count":1,"href":"https:\/\/ronniee.net\/index.php?rest_route=\/wp\/v2\/posts\/80\/revisions"}],"predecessor-version":[{"id":81,"href":"https:\/\/ronniee.net\/index.php?rest_route=\/wp\/v2\/posts\/80\/revisions\/81"}],"wp:attachment":[{"href":"https:\/\/ronniee.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ronniee.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ronniee.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}