{"id":12193,"date":"2022-05-11T04:40:03","date_gmt":"2022-05-11T08:40:03","guid":{"rendered":"http:\/\/local.brightwhiz\/?post_type=snippets&p=12193"},"modified":"2022-05-11T04:40:05","modified_gmt":"2022-05-11T08:40:05","slug":"php-check-if-date-is-greater-than-today","status":"publish","type":"snippets","link":"http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/","title":{"rendered":"Check if Date is Greater Than Today Using PHP"},"content":{"rendered":"\n

Use this code snippet to check if date is greater than today.<\/p>\n\n\n\n

$date_today = new DateTime();\n$existing_date = new DateTime( "01\/02\/2023" );\n\nif ( $date_today > $existing_date ) {\n\n   echo "greater than today";\n\n} else {\n\n   echo "Less than today";\n\n}<\/code><\/pre>\n\n\n\n

Alternate:<\/p>\n\n\n\n

$date_today = date("Y-m-d");\n$existing_date = "2023-01-02";\n\nif ( $date_today > '2016-01-02') {\n\n   echo "greater than today";\n\n} else {\n\n   echo "Less than today";\n\n}<\/code><\/pre>\n","protected":false},"comment_status":"open","ping_status":"closed","template":"","meta":[],"categories":[953,23,25,27,15,16],"tags":[433,449,452,471,544,638],"yoast_head":"\nPHP Check if Date is Greater Than Today Example<\/title>\n<meta name=\"description\" content=\"you can check if date is greater than today using this example of a PHP code snippet also useful for checking other variations\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP Check if Date is Greater Than Today Example\" \/>\n<meta property=\"og:description\" content=\"you can check if date is greater than today using this example of a PHP code snippet also useful for checking other variations\" \/>\n<meta property=\"og:url\" content=\"http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/\" \/>\n<meta property=\"og:site_name\" content=\"Brightwhiz.com\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/brightwhiz\/\" \/>\n<meta property=\"article:modified_time\" content=\"2022-05-11T08:40:05+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@brightwhizmag\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/\",\"url\":\"http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/\",\"name\":\"PHP Check if Date is Greater Than Today Example\",\"isPartOf\":{\"@id\":\"http:\/\/local.brightwhiz\/#website\"},\"datePublished\":\"2022-05-11T08:40:03+00:00\",\"dateModified\":\"2022-05-11T08:40:05+00:00\",\"description\":\"you can check if date is greater than today using this example of a PHP code snippet also useful for checking other variations\",\"breadcrumb\":{\"@id\":\"http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/local.brightwhiz\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Snippets\",\"item\":\"http:\/\/local.brightwhiz\/snippets\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Check if Date is Greater Than Today Using PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/local.brightwhiz\/#website\",\"url\":\"http:\/\/local.brightwhiz\/\",\"name\":\"Brightwhiz.com\",\"description\":\"Best Tech guides, Tutorials, and News\",\"publisher\":{\"@id\":\"http:\/\/local.brightwhiz\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/local.brightwhiz\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/local.brightwhiz\/#organization\",\"name\":\"Brightwhiz\",\"url\":\"http:\/\/local.brightwhiz\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png\",\"contentUrl\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png\",\"width\":706,\"height\":135,\"caption\":\"Brightwhiz\"},\"image\":{\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/brightwhiz\/\",\"https:\/\/twitter.com\/brightwhizmag\",\"https:\/\/instagram.com\/bright_whiz\/\",\"https:\/\/www.pinterest.com\/sobbayi\/\",\"https:\/\/www.youtube.com\/channel\/UC6sCdP_d_RiTIM7ErFT-PSQ\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP Check if Date is Greater Than Today Example","description":"you can check if date is greater than today using this example of a PHP code snippet also useful for checking other variations","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/","og_locale":"en_US","og_type":"article","og_title":"PHP Check if Date is Greater Than Today Example","og_description":"you can check if date is greater than today using this example of a PHP code snippet also useful for checking other variations","og_url":"http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/","og_site_name":"Brightwhiz.com","article_publisher":"https:\/\/www.facebook.com\/brightwhiz\/","article_modified_time":"2022-05-11T08:40:05+00:00","twitter_card":"summary_large_image","twitter_site":"@brightwhizmag","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/","url":"http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/","name":"PHP Check if Date is Greater Than Today Example","isPartOf":{"@id":"http:\/\/local.brightwhiz\/#website"},"datePublished":"2022-05-11T08:40:03+00:00","dateModified":"2022-05-11T08:40:05+00:00","description":"you can check if date is greater than today using this example of a PHP code snippet also useful for checking other variations","breadcrumb":{"@id":"http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/local.brightwhiz\/snippets\/php-check-if-date-is-greater-than-today\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/local.brightwhiz\/"},{"@type":"ListItem","position":2,"name":"Snippets","item":"http:\/\/local.brightwhiz\/snippets\/"},{"@type":"ListItem","position":3,"name":"Check if Date is Greater Than Today Using PHP"}]},{"@type":"WebSite","@id":"http:\/\/local.brightwhiz\/#website","url":"http:\/\/local.brightwhiz\/","name":"Brightwhiz.com","description":"Best Tech guides, Tutorials, and News","publisher":{"@id":"http:\/\/local.brightwhiz\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/local.brightwhiz\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/local.brightwhiz\/#organization","name":"Brightwhiz","url":"http:\/\/local.brightwhiz\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/","url":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png","contentUrl":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png","width":706,"height":135,"caption":"Brightwhiz"},"image":{"@id":"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/brightwhiz\/","https:\/\/twitter.com\/brightwhizmag","https:\/\/instagram.com\/bright_whiz\/","https:\/\/www.pinterest.com\/sobbayi\/","https:\/\/www.youtube.com\/channel\/UC6sCdP_d_RiTIM7ErFT-PSQ"]}]}},"_links":{"self":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/snippets\/12193"}],"collection":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/snippets"}],"about":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/types\/snippets"}],"replies":[{"embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/comments?post=12193"}],"wp:attachment":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/media?parent=12193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/categories?post=12193"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/tags?post=12193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}