{"id":2076,"date":"2015-06-17T15:43:24","date_gmt":"2015-06-17T15:43:24","guid":{"rendered":"https:\/\/raspberry-projects.com\/pi\/?p=2076"},"modified":"2015-06-17T15:46:08","modified_gmt":"2015-06-17T15:46:08","slug":"set-the-rpi-time","status":"publish","type":"post","link":"https:\/\/raspberry-projects.com\/pi\/programming-in-c\/datetime\/set-the-rpi-time","title":{"rendered":"Set the RPi Time"},"content":{"rendered":"<h4>\nSet the RPi Date and Time<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\ttm gps_date_time;\r\n\tchar TimeString[128];\r\n\r\n\tgps_date_time.tm_year = 20;\r\n\tgps_date_time.tm_mon = 1;\r\n\tgps_date_time.tm_mday = 1;\r\n\tgps_date_time.tm_hour = 1;\r\n\tgps_date_time.tm_min = 1;\r\n\tgps_date_time.tm_sec = 1;\r\n\r\n\tstrftime(TimeString, 80, &quot;%Y-%m-%dT%H:%M:%S&quot;, &amp;gps_date_time);\r\n\tSetDataTimeString = &quot;sudo date -s &quot;;\r\n\tSetDataTimeString += TimeString;\r\n\r\n\t\/\/Set the RPi time\r\n\tsystem((const char*)SetDataTimeString.c_str());\r\n<\/code><\/pre>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Set the RPi Date and Time tm gps_date_time; char TimeString[128]; gps_date_time.tm_year = 20; gps_date_time.tm_mon = 1; gps_date_time.tm_mday = 1; gps_date_time.tm_hour = 1; gps_date_time.tm_min = 1; gps_date_time.tm_sec = 1; strftime(TimeString, 80, &quot;%Y-%m-%dT%H:%M:%S&quot;, &amp;gps_date_time); SetDataTimeString = &quot;sudo date -s &quot;; SetDataTimeString += TimeString; \/\/Set the RPi time system((const char*)SetDataTimeString.c_str()); &nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[86],"tags":[],"class_list":["post-2076","post","type-post","status-publish","format-standard","hentry","category-datetime"],"_links":{"self":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/2076","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/comments?post=2076"}],"version-history":[{"count":2,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/2076\/revisions"}],"predecessor-version":[{"id":2078,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/2076\/revisions\/2078"}],"wp:attachment":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/media?parent=2076"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/categories?post=2076"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/tags?post=2076"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}