{"id":111,"date":"2009-12-01T12:15:13","date_gmt":"2009-12-01T12:15:13","guid":{"rendered":"http:\/\/blog.soton.ac.uk\/webteam\/2009\/12\/01\/timezone-vs-time-offset\/"},"modified":"2009-12-01T12:17:13","modified_gmt":"2009-12-01T12:17:13","slug":"timezone-vs-time-offset","status":"publish","type":"post","link":"https:\/\/blog.soton.ac.uk\/webteam\/2009\/12\/01\/timezone-vs-time-offset\/","title":{"rendered":"Timezone vs Time Offset"},"content":{"rendered":"<p>Time is a bit like character sets, in that you can more or less get something useful by guesswork on the data, but that&#8217;s not safe for key systems.<\/p>\n<p>A place, or system, has a timezone such as &#8220;Europe\/London&#8221;. A time should either have a time-offset (eg. +0100 or BST) stored with it, OR it can be assumed to be in the timezone for the system running it.<\/p>\n<p>What is important is that when converting datetimes (without explicit offsets) to exact times in seconds (UNIX time_t), that you convert using the offset that was true on the date, not the current offset.<\/p>\n<p>Like UTF-8, you can&#8217;t always tell by looking what a time means. Don&#8217;t use the MSSQL DATEDIFF() function as it appears to use the current offset (ie GMT) rather than the offset which was true at the given date (BST). This is a subtle issue, and long really bites if converting DATETIME to UNIX time.<\/p>\n<p>The moral of the story is, like with character sets, to use a damn library, and that just because the output looks correct, doesn&#8217;t mean it is.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Time is a bit like character sets, in that you can more or less get something useful by guesswork on the data, but that&#8217;s not safe for key systems. A place, or system, has a timezone such as &#8220;Europe\/London&#8221;. A time should either have a time-offset (eg. +0100 or BST) stored with it, OR it [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[1],"tags":[193],"class_list":["post-111","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-time-data-sql"],"_links":{"self":[{"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/posts\/111","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/comments?post=111"}],"version-history":[{"count":2,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/posts\/111\/revisions"}],"predecessor-version":[{"id":112,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/posts\/111\/revisions\/112"}],"wp:attachment":[{"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/media?parent=111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/categories?post=111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/tags?post=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}