{"id":4983,"date":"2025-12-17T20:16:37","date_gmt":"2025-12-17T20:16:37","guid":{"rendered":"https:\/\/ibex.tech\/python\/?p=4983"},"modified":"2025-12-17T20:16:37","modified_gmt":"2025-12-17T20:16:37","slug":"is-the-datetime-valid","status":"publish","type":"post","link":"https:\/\/ibex.tech\/python\/date-and-time\/is-the-datetime-valid","title":{"rendered":"Is the DateTime valid?"},"content":{"rendered":"\n<p>On hardware like the Raspberry Pi there is no battery back clock so the OS has to get the DateTime via NTP.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Simple invalid value check<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>from datetime import datetime\n\n    if (datetime.now().year &gt;= 2025):       #This catches, 1970-01-01, 2000-01-01, basically any power-up default clock (not perfect but commonly used in embedded systems)\n        return True<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>On hardware like the Raspberry Pi there is no battery back clock so the OS has to get the DateTime via NTP. Simple invalid value check<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[339],"tags":[],"class_list":["post-4983","post","type-post","status-publish","format-standard","hentry","category-date-and-time"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts\/4983","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/comments?post=4983"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts\/4983\/revisions"}],"predecessor-version":[{"id":4984,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/posts\/4983\/revisions\/4984"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/media?parent=4983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/categories?post=4983"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/python\/wp-json\/wp\/v2\/tags?post=4983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}