{"id":22049,"date":"2021-03-09T01:01:11","date_gmt":"2021-03-09T06:01:11","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/php-date-time-examples-software-development-web-development-root-by-sayed-ahmed\/"},"modified":"2021-03-09T01:01:11","modified_gmt":"2021-03-09T06:01:11","slug":"php-date-time-examples-software-development-web-development-root-by-sayed-ahmed","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=22049","title":{"rendered":"PHP Date Time Examples #Software Development #Web Development #Root #By Sayed Ahmed"},"content":{"rendered":"<p>You can use the following code where users can select a date range from a drop down with quick dates. Very often, you will also need a date range calendar; you can use jquery date picker tool for the purpose.<\/p>\n<p>if ($quickDates==&#8221;today&#8221;){<br \/>\n$dateFrom = date(&#8220;Y-m-d&#8221;);<br \/>\n$dateTo = date(&#8220;Y-m-d&#8221;, time() + 60 * 60 * 24);<br \/>\n}else if ($quickDates==&#8221;yesterday&#8221;){<br \/>\n$dateFrom = date(&#8220;Y-m-d&#8221;, time() &#8211; 60 * 60 * 24);<br \/>\n$dateTo = date(&#8220;Y-m-d&#8221;);<br \/>\n}else if ($quickDates==&#8221;lastWeek&#8221;){<br \/>\n$dateFrom = date(&#8220;Y-m-d&#8221;, time() &#8211; 7*60 * 60 * 24);<br \/>\n$dateTo = date(&#8220;Y-m-d&#8221;);<br \/>\n}else if ($quickDates==&#8221;thisMonth&#8221;){<br \/>\n$dateFrom = date(&#8220;Y-m-1&#8221;);<br \/>\n$dateTo = date(&#8220;Y-m-d&#8221;,strtotime(&#8220;+1 months&#8221;));<br \/>\n}else if ($quickDates==&#8221;lastMonth&#8221;){<br \/>\n$dateFrom = date(&#8220;Y-m-d&#8221;,strtotime(&#8220;-1 months&#8221;));<br \/>\n$dateTo = date(&#8220;Y-m&#8221;);<br \/>\n}else if ($quickDates==&#8221;allTime&#8221;){<br \/>\n$dateFrom = &#8220;all&#8221;;<br \/>\n$dateTo = &#8220;all&#8221;;<br \/>\n}<\/p>\n<p>You can utilize this range in a query as follows<\/p>\n<p>$dateFilter = &#8220;&#8221;;<br \/>\nif ($dateFrom != &#8220;all&#8221;){<br \/>\n$dateFilter = &#8221; where ( date &gt;= &#8216;$dateFrom&#8217; and date &lt; &#8216;$dateTo&#8217;) &#8220;;<br \/>\n}<\/p>\n<p>$sql = &#8221; select * from table $dateFilter order by date desc&#8221;;<\/p>\n<p>HTML for a quick date selector can be as folows:<\/p>\n<p>&lt;select id=&#8217;cmbQuickDates&#8217; name=&#8217;cmbQuickDates&#8217;&gt;<br \/>\n&lt;option value=&#8221;&gt;Select&lt;\/option&gt;<br \/>\n&lt;option value=&#8217;today&#8217;&gt;Today&lt;\/option&gt;<br \/>\n&lt;option value=&#8217;yesterday&#8217;&gt;Yesterday&lt;\/option&gt;<br \/>\n&lt;option value=&#8217;lastWeek&#8217;&gt;Last week&lt;\/option&gt;<br \/>\n&lt;option value=&#8217;thisMonth&#8217;&gt;This month&lt;\/option&gt;<br \/>\n&lt;option value=&#8217;lastMonth&#8217;&gt;Last month&lt;\/option&gt;<br \/>\n&lt;option value=&#8217;allTime&#8217;&gt;All time&lt;\/option&gt;<br \/>\n&lt;{\/select&gt; From: http:\/\/sitestree.com\/?p=147<br \/> Categories:Software Development, Web Development, Root, By Sayed Ahmed<br \/>Tags:PHP, Date<br \/> Post Data:2013-01-01 05:52:23<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can use the following code where users can select a date range from a drop down with quick dates. Very often, you will also need a date range calendar; you can use jquery date picker tool for the purpose. if ($quickDates==&#8221;today&#8221;){ $dateFrom = date(&#8220;Y-m-d&#8221;); $dateTo = date(&#8220;Y-m-d&#8221;, time() + 60 * 60 * 24); &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=22049\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-22049","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":6061,"url":"http:\/\/bangla.sitestree.com\/?p=6061","url_meta":{"origin":22049,"position":0},"title":"\u09aa\u09bf\u098f\u0987\u099a\u09aa\u09bf \u09eb \u09a4\u09be\u09b0\u09bf\u0996 \u0993 \u09b8\u09ae\u09df (PHP 5 Date and Time)","author":"Author-Check- Article-or-Video","date":"March 10, 2015","format":false,"excerpt":"PHP Date() \u09ab\u09be\u0982\u09b6\u09a8 PHP Date() \u09ab\u09be\u0982\u09b6\u09a8 \u098f\u09b0 \u09ae\u09be\u09a7\u09cd\u09af\u09ae\u09c7 \u09b8\u09b9\u099c\u09c7 \u0993 \u09b8\u09a0\u09bf\u0995\u09ad\u09be\u09ac\u09c7 \u09b8\u09ae\u09df (time) \u0993 \u09a4\u09be\u09b0\u09bf\u0996 (date) \u09a6\u09c7\u0996\u09be\u09a8\u09cb \u09af\u09be\u09df\u0964 \u09b8\u09bf\u09a8\u099f\u09c7\u0995\u09cd\u09b8 date(format,timestamp) \u00a0 \u09aa\u09cd\u09af\u09be\u09b0\u09be\u09ae\u09bf\u099f\u09be\u09b0 \u09ac\u09b0\u09cd\u09a3\u09a8\u09be format \u0986\u09ac\u09b6\u09cd\u09af\u09bf\u0995 \u09ac\u09be Required. \u098f\u09b0 \u09b8\u09be\u09b9\u09be\u09af\u09cd\u09af\u09c7 timestamp \u098f\u09b0 \u09ab\u09b0\u09ae\u09c7\u099f \u09a8\u09bf\u09b0\u09cd\u09a6\u09bf\u09b7\u09cd\u099f \u0995\u09b0\u09be \u09b9\u09df\u0964 timestamp \u0990\u099a\u09cd\u099b\u09bf\u0995 \u09ac\u09be Optional. \u098f\u09b0 \u09b8\u09be\u09b9\u09be\u09af\u09cd\u09af\u09c7 timestamp \u09a8\u09bf\u09b0\u09cd\u09a6\u09bf\u09b7\u09cd\u099f \u0995\u09b0\u09be \u09b9\u09df\u0964 \u09b8\u09be\u09a7\u09be\u09b0\u09a3\u09a4 Default \u09b9\u09bf\u09b8\u09be\u09ac\u09c7 current \u09b8\u09ae\u09df\u2026","rel":"","context":"In &quot;\u09aa\u09bf \u098f\u0987\u099a \u09aa\u09bf \u099f\u09bf\u0989\u099f\u09cb\u09b0\u09bf\u09df\u09be\u09b2 \u0964 PHP tutorial&quot;","block_context":{"text":"\u09aa\u09bf \u098f\u0987\u099a \u09aa\u09bf \u099f\u09bf\u0989\u099f\u09cb\u09b0\u09bf\u09df\u09be\u09b2 \u0964 PHP tutorial","link":"http:\/\/bangla.sitestree.com\/?cat=172"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5967,"url":"http:\/\/bangla.sitestree.com\/?p=5967","url_meta":{"origin":22049,"position":1},"title":"SQL Date Functions","author":"Author-Check- Article-or-Video","date":"January 30, 2015","format":false,"excerpt":"\u09a8\u09be\u09ae-\u09b6\u09b0\u09bf\u09ab\u09c1\u09b2 \u0987\u09b8\u09b2\u09be\u09ae Job category-Php Coder \u09ac\u09bf\u09b7\u09df- SQL Date Functions \u098f\u099f\u09bf \u098f\u0995\u099f\u09bf \u0995\u09a0\u09bf\u09a8 \u09ac\u09bf\u09b7\u09df \u09af\u0996\u09a8 \u0986\u09ae\u09b0\u09be date \u09a8\u09bf\u09df\u09c7 \u0995\u09be\u099c \u0995\u09b0\u09ac \u09a8\u09bf\u09b0\u09cd\u09a6\u09bf\u09b7\u09cd\u099f \u09ad\u09be\u09ac\u09c7 \u0986\u09ae\u09be\u09a6\u09c7\u09b0 date format \u099c\u09c7\u09a8\u09c7 \u09a8\u09bf\u09a4\u09c7 \u09b9\u09ac\u09c7\u0964\u0986\u09ae\u09b0\u09be date \u09a8\u09bf\u09df\u09c7 \u0995\u09be\u099c \u0995\u09b0\u09a4\u09c7 \u0997\u09c7\u09b2\u09c7 \u098f\u09b0 \u0995\u09df\u09c7\u0995\u099f\u09bf \u09ab\u09b0\u09ae\u09cd\u09af\u09be\u099f \u0986\u09ae\u09be\u09a6\u09c7\u09b0 \u099c\u09be\u09a8\u09a4\u09c7 \u09b9\u09ac\u09c7\u0964 Now()-\u09ac\u09b0\u09cd\u09a4\u09ae\u09be\u09a8 \u09b8\u09ae\u09df \u098f\u09ac\u0982 \u09a4\u09be\u09b0\u09bf\u0996 \u09aa\u09be\u0993\u09df\u09be \u09af\u09be\u09ac\u09c7 CURDATE()-\u09ac\u09b0\u09cd\u09a4\u09ae\u09be\u09a8 \u09a4\u09be\u09b0\u09bf\u0996 \u09aa\u09be\u0993\u09df\u09be \u09af\u09be\u09ac\u09c7 CURTIME()-\u09ac\u09b0\u09cd\u09a4\u09ae\u09be\u09a8 \u09b8\u09ae\u09df\u2026","rel":"","context":"In &quot;\u098f\u09b8 \u0995\u09bf\u0989 \u098f\u09b2 - \u09e6\u09e6\u09e7 \u0964 SQL - 001&quot;","block_context":{"text":"\u098f\u09b8 \u0995\u09bf\u0989 \u098f\u09b2 - \u09e6\u09e6\u09e7 \u0964 SQL - 001","link":"http:\/\/bangla.sitestree.com\/?cat=155"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65722,"url":"http:\/\/bangla.sitestree.com\/?p=65722","url_meta":{"origin":22049,"position":2},"title":"Topic 1: Basic Date Displaying Shell Script #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 12, 2021","format":false,"excerpt":"bash-3.2$ cat echoscript1.sh #!\/bin\/sh #clear echo \"SCRIPT BEGINS\" echo \"Hello $LOGNAME\" echo echo \"Todays date is: c\" date '+%m\/%d\/%y' echo \"and the current time is: c\" date '+%H:%M:%S%n' echo \"Now a list of the processes in the current shell\" ps echo \"SCRIPT FINISHED!!\" bash-3.2$ .\/echoscript1.sh SCRIPT BEGINS Hello shell Todays\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65724,"url":"http:\/\/bangla.sitestree.com\/?p=65724","url_meta":{"origin":22049,"position":3},"title":"Korn Shell Example: Show Dates #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 12, 2021","format":false,"excerpt":"bash-3.2$ cat echoscript2.ksh #!\/bin\/ksh #clear print \"SCRIPT BEGINS\" print \"Hello $LOGNAME\" print print -n \"Todays date is: \" date '+%m\/%d\/%y' print -n \"and the current time is: \" date '+%H:%M:%S%n' print \"Now a list of the processes in the current shell\" ps print \"SCRIPT FINISHED!!\" bash-3.2$ .\/echoscript2.ksh SCRIPT BEGINS Hello\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65685,"url":"http:\/\/bangla.sitestree.com\/?p=65685","url_meta":{"origin":22049,"position":4},"title":"A Basic Shell Program #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 11, 2021","format":false,"excerpt":"#!\/bin\/sh #if enabled - will spit out the script to the screen #set -v #clear the screen clear echo \"SCRIPT BEGINS\" #shows current login name echo \"Hello $LOGNAME\" #shows current date in the same line echo \"Todays date is: c\" date +%m\/%d\/%y #shows current time in the same line echo\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65718,"url":"http:\/\/bangla.sitestree.com\/?p=65718","url_meta":{"origin":22049,"position":5},"title":"On Thursday and Friday tar all contents of \/etc folder into \/export\/home\/shell\/test\/etc.tar .. do misc logs #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 12, 2021","format":false,"excerpt":"#!\/bin\/ksh # on every thursday and friday tar all contents of \/etc folder into \/export\/home\/shell\/test\/. On thursday only create a log file with the list of files #in the tar file. On thursday untar \/export\/home\/shell\/test\/etc.tar into vfstab . Then log vfstab exist or not information DAY=`date +%a` DATESTAMP=`date +%m-%d-%Y-%H:%M` if\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/22049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=22049"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/22049\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=22049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=22049"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=22049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}