{"id":1059,"date":"2024-04-16T20:05:17","date_gmt":"2024-04-16T11:05:17","guid":{"rendered":"http:\/\/inwelly.com\/?p=1059"},"modified":"2024-04-23T04:29:47","modified_gmt":"2024-04-22T19:29:47","slug":"php-expiry-day-how-to-convert-datetimemysql-to-mktime-of-php","status":"publish","type":"post","link":"https:\/\/inwelly.com\/?p=1059","title":{"rendered":"\u00a0PHP Expiry day : How to convert datetime(mysql) to mktime of php"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>&nbsp;function getMktimeNumber($type,$date)<\/p>\n\n\n\n<p>&nbsp; &nbsp;&nbsp;{<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if($type &gt; 0)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;{<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;$convert = strtotime($date);<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;$times = date(&#8220;H,i,s,m,d,Y&#8221;,$convert);<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;else<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;{<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;$times = date(&#8220;H,i,s,m,d,Y&#8221;,time());<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;$cut = explode(&#8220;,&#8221;,$times);<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;$time_number = mktime($cut[0] , $cut[1] , $cut[2] , $cut[3] , $cut[4] , $cut[5]&nbsp;&nbsp;);<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return $time_number;<\/p>\n\n\n\n<p>&nbsp; &nbsp;&nbsp;}<\/p>\n\n\n\n<p>$start_time = \u20182023-11-15 11:01:19\u2019;<\/p>\n\n\n\n<p>$untilDay = 3 ;<\/p>\n\n\n\n<p>$time1 = $this-&gt;getMktimeNumber(1,$start_time]);&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ Start date<\/p>\n\n\n\n<p>$time2 = $this-&gt;getMktimeNumber(0,time());&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ Now date<\/p>\n\n\n\n<p>$time3 = $time1 + ( (3600*24)* ($untilDay*1) );&nbsp;&nbsp; &nbsp;&nbsp;\/\/ Expiry date<\/p>\n\n\n\n<p>if( $time2 &gt;= $time3 )<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>exit;<\/p>\n\n\n\n<p>}<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;function getMktimeNumber($type,$date) &nbsp; &nbsp;&nbsp;{ &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if($type &gt; 0) &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;$convert [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1251,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1059","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/1059","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1059"}],"version-history":[{"count":1,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/1059\/revisions"}],"predecessor-version":[{"id":1060,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/1059\/revisions\/1060"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/media\/1251"}],"wp:attachment":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}