{"id":117,"date":"2014-12-18T11:17:57","date_gmt":"2014-12-18T02:17:57","guid":{"rendered":"https:\/\/www.crestboz.co.jp\/techblog\/?p=117"},"modified":"2016-09-17T17:11:31","modified_gmt":"2016-09-17T08:11:31","slug":"datetime%e5%9e%8b%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e3%81%a7%e5%bc%95%e3%81%8d%e7%ae%97%e3%82%92%e8%a1%8c%e3%81%aa%e3%81%86","status":"publish","type":"post","link":"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/","title":{"rendered":"Python\u306edatetime\u578b\u306e\u30c7\u30fc\u30bf\u3067\u5f15\u304d\u7b97\u3092\u884c\u306a\u3046"},"content":{"rendered":"<p>\u4f8b\u3048\u3070\u90e8\u5c4b\u306a\u3069\u306e\u4e88\u7d04\u3092\u3059\u308b\u5834\u5408\u3001\u4f7f\u7528\u958b\u59cb\u6642\u523b\u3068\u4f7f\u7528\u7d42\u4e86\u6642\u523b\u304c\u5165\u529b\u3055\u308c\u3001\u4f55\u6642\u9593\u4f7f\u7528\u3057\u305f\u304b\u3092\u7b97\u51fa\u3057\u305f\u3044\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>\u6642\u523b\u306e\u30c7\u30fc\u30bf\u578b\u306fdatetime\u578b\u3068\u3057\u307e\u3059\u3002<br \/>\nPython\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f2.7.6\u3067\u3059\u3002<\/p>\n<p>[\u4f8b1]<br \/>\n\u4f7f\u7528\u958b\u59cb\u6642\u523b\uff1a2014\u5e7412\u670818\u65e5 10:00<br \/>\n\u4f7f\u7528\u7d42\u4e86\u6642\u523b\uff1a2014\u5e7412\u670818\u65e5 11:30<br \/>\n\u4f7f\u7528\u6642\u9593\uff1a1.5(h)<\/p>\n<pre class=\"striped:false highlight:0 nums:false lang:sh decode:false \" >\r\n>>> import datetime\r\n>>> a = datetime.datetime(2014, 12, 18, 10, 0, 0)\r\n>>> b = datetime.datetime(2014, 12, 18, 11, 30, 0)\r\n>>> diff = b - a\r\n>>> diff\r\ndatetime.timedelta(0, 5400)\r\n>>> diff.seconds\r\n5400\r\n>>> float(diff.seconds) \/ 3600\r\n1.5\r\n<\/pre>\n<p>24\u6642\u9593\u3092\u8d85\u3048\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u5834\u5408\u306f <code>total_seconds()<\/code> \u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3068\u3046\u307e\u304f\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>[\u4f8b2]<br \/>\n\u4f7f\u7528\u958b\u59cb\u6642\u523b\uff1a2014\u5e7412\u670819\u65e5 12:00<br \/>\n\u4f7f\u7528\u7d42\u4e86\u6642\u523b\uff1a2014\u5e7412\u670820\u65e5 13:30<br \/>\n\u4f7f\u7528\u6642\u9593\uff1a25.5(h)<\/p>\n<pre class=\"striped:false highlight:0 nums:false lang:sh decode:false \" >\r\n>>> import datetime\r\n>>> a = datetime.datetime(2014, 12, 19, 12, 0, 0)\r\n>>> b = datetime.datetime(2014, 12, 20, 13, 30, 0)\r\n>>> diff = b - a\r\n>>> diff\r\ndatetime.timedelta(1, 5400)\r\n>>> diff.seconds\r\n5400\r\n>>> diff.total_seconds()\r\n91800.0\r\n>>> diff.total_seconds() \/ 3600\r\n25.5\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4f8b\u3048\u3070\u90e8\u5c4b\u306a\u3069\u306e\u4e88\u7d04\u3092\u3059\u308b\u5834\u5408\u3001\u4f7f\u7528\u958b\u59cb\u6642\u523b\u3068\u4f7f\u7528\u7d42\u4e86\u6642\u523b\u304c\u5165\u529b\u3055\u308c\u3001\u4f55\u6642\u9593\u4f7f\u7528\u3057\u305f\u304b\u3092\u7b97\u51fa\u3057\u305f\u3044\u3068\u3057\u307e\u3059\u3002 \u6642\u523b\u306e\u30c7\u30fc\u30bf\u578b\u306fdatetime\u578b\u3068\u3057\u307e\u3059\u3002 Python\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f2.7.6\u3067\u3059\u3002 [\u4f8b1] \u4f7f\u7528\u958b\u59cb\u6642 [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-117","post","type-post","status-publish","format-standard","hentry","category-python","wpautop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python\u306edatetime\u578b\u306e\u30c7\u30fc\u30bf\u3067\u5f15\u304d\u7b97\u3092\u884c\u306a\u3046 - \u30af\u30ec\u30b9\u30c8\u30dc\u30a6\u30ba::\u6280\u8853\u8005\u30d6\u30ed\u30b0<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python\u306edatetime\u578b\u306e\u30c7\u30fc\u30bf\u3067\u5f15\u304d\u7b97\u3092\u884c\u306a\u3046 - \u30af\u30ec\u30b9\u30c8\u30dc\u30a6\u30ba::\u6280\u8853\u8005\u30d6\u30ed\u30b0\" \/>\n<meta property=\"og:description\" content=\"\u4f8b\u3048\u3070\u90e8\u5c4b\u306a\u3069\u306e\u4e88\u7d04\u3092\u3059\u308b\u5834\u5408\u3001\u4f7f\u7528\u958b\u59cb\u6642\u523b\u3068\u4f7f\u7528\u7d42\u4e86\u6642\u523b\u304c\u5165\u529b\u3055\u308c\u3001\u4f55\u6642\u9593\u4f7f\u7528\u3057\u305f\u304b\u3092\u7b97\u51fa\u3057\u305f\u3044\u3068\u3057\u307e\u3059\u3002 \u6642\u523b\u306e\u30c7\u30fc\u30bf\u578b\u306fdatetime\u578b\u3068\u3057\u307e\u3059\u3002 Python\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f2.7.6\u3067\u3059\u3002 [\u4f8b1] \u4f7f\u7528\u958b\u59cb\u6642 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/\" \/>\n<meta property=\"og:site_name\" content=\"\u30af\u30ec\u30b9\u30c8\u30dc\u30a6\u30ba::\u6280\u8853\u8005\u30d6\u30ed\u30b0\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/crestboz\" \/>\n<meta property=\"article:published_time\" content=\"2014-12-18T02:17:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-09-17T08:11:31+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@crestboz\" \/>\n<meta name=\"twitter:site\" content=\"@crestboz\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"Python\u306edatetime\u578b\u306e\u30c7\u30fc\u30bf\u3067\u5f15\u304d\u7b97\u3092\u884c\u306a\u3046\",\"datePublished\":\"2014-12-18T02:17:57+00:00\",\"dateModified\":\"2016-09-17T08:11:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/\"},\"wordCount\":6,\"publisher\":{\"@id\":\"https:\/\/www.crestboz.co.jp\/techblog\/#organization\"},\"articleSection\":[\"Python\"],\"inLanguage\":\"ja\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/\",\"url\":\"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/\",\"name\":\"Python\u306edatetime\u578b\u306e\u30c7\u30fc\u30bf\u3067\u5f15\u304d\u7b97\u3092\u884c\u306a\u3046 - \u30af\u30ec\u30b9\u30c8\u30dc\u30a6\u30ba::\u6280\u8853\u8005\u30d6\u30ed\u30b0\",\"isPartOf\":{\"@id\":\"https:\/\/www.crestboz.co.jp\/techblog\/#website\"},\"datePublished\":\"2014-12-18T02:17:57+00:00\",\"dateModified\":\"2016-09-17T08:11:31+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u30db\u30fc\u30e0\",\"item\":\"https:\/\/www.crestboz.co.jp\/techblog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\u306edatetime\u578b\u306e\u30c7\u30fc\u30bf\u3067\u5f15\u304d\u7b97\u3092\u884c\u306a\u3046\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.crestboz.co.jp\/techblog\/#website\",\"url\":\"https:\/\/www.crestboz.co.jp\/techblog\/\",\"name\":\"\u30af\u30ec\u30b9\u30c8\u30dc\u30a6\u30ba::\u6280\u8853\u8005\u30d6\u30ed\u30b0\",\"description\":\"IT\u95a2\u9023\u306e\u6280\u8853\u7684\u306a\u3053\u3068\u306b\u95a2\u3057\u3066\u8abf\u67fb\u3057\u305f\u3053\u3068\u306a\u3069\u3092\u516c\u958b\u3059\u308b\u30d6\u30ed\u30b0\u3067\u3059\",\"publisher\":{\"@id\":\"https:\/\/www.crestboz.co.jp\/techblog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.crestboz.co.jp\/techblog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ja\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.crestboz.co.jp\/techblog\/#organization\",\"name\":\"\u30af\u30ec\u30b9\u30c8\u30dc\u30a6\u30ba\u682a\u5f0f\u4f1a\u793e\",\"url\":\"https:\/\/www.crestboz.co.jp\/techblog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.crestboz.co.jp\/techblog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.crestboz.co.jp\/techblog\/wp-content\/uploads\/2019\/12\/robot.png\",\"contentUrl\":\"https:\/\/www.crestboz.co.jp\/techblog\/wp-content\/uploads\/2019\/12\/robot.png\",\"width\":387,\"height\":387,\"caption\":\"\u30af\u30ec\u30b9\u30c8\u30dc\u30a6\u30ba\u682a\u5f0f\u4f1a\u793e\"},\"image\":{\"@id\":\"https:\/\/www.crestboz.co.jp\/techblog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/crestboz\",\"https:\/\/x.com\/crestboz\"]},{\"@type\":\"Person\",\"@id\":\"\",\"url\":\"https:\/\/www.crestboz.co.jp\/techblog\/archives\/author\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python\u306edatetime\u578b\u306e\u30c7\u30fc\u30bf\u3067\u5f15\u304d\u7b97\u3092\u884c\u306a\u3046 - \u30af\u30ec\u30b9\u30c8\u30dc\u30a6\u30ba::\u6280\u8853\u8005\u30d6\u30ed\u30b0","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":"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/","og_locale":"ja_JP","og_type":"article","og_title":"Python\u306edatetime\u578b\u306e\u30c7\u30fc\u30bf\u3067\u5f15\u304d\u7b97\u3092\u884c\u306a\u3046 - \u30af\u30ec\u30b9\u30c8\u30dc\u30a6\u30ba::\u6280\u8853\u8005\u30d6\u30ed\u30b0","og_description":"\u4f8b\u3048\u3070\u90e8\u5c4b\u306a\u3069\u306e\u4e88\u7d04\u3092\u3059\u308b\u5834\u5408\u3001\u4f7f\u7528\u958b\u59cb\u6642\u523b\u3068\u4f7f\u7528\u7d42\u4e86\u6642\u523b\u304c\u5165\u529b\u3055\u308c\u3001\u4f55\u6642\u9593\u4f7f\u7528\u3057\u305f\u304b\u3092\u7b97\u51fa\u3057\u305f\u3044\u3068\u3057\u307e\u3059\u3002 \u6642\u523b\u306e\u30c7\u30fc\u30bf\u578b\u306fdatetime\u578b\u3068\u3057\u307e\u3059\u3002 Python\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f2.7.6\u3067\u3059\u3002 [\u4f8b1] \u4f7f\u7528\u958b\u59cb\u6642 [&hellip;]","og_url":"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/","og_site_name":"\u30af\u30ec\u30b9\u30c8\u30dc\u30a6\u30ba::\u6280\u8853\u8005\u30d6\u30ed\u30b0","article_publisher":"https:\/\/www.facebook.com\/crestboz","article_published_time":"2014-12-18T02:17:57+00:00","article_modified_time":"2016-09-17T08:11:31+00:00","twitter_card":"summary_large_image","twitter_creator":"@crestboz","twitter_site":"@crestboz","twitter_misc":{"\u57f7\u7b46\u8005":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/#article","isPartOf":{"@id":"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/"},"author":{"name":"","@id":""},"headline":"Python\u306edatetime\u578b\u306e\u30c7\u30fc\u30bf\u3067\u5f15\u304d\u7b97\u3092\u884c\u306a\u3046","datePublished":"2014-12-18T02:17:57+00:00","dateModified":"2016-09-17T08:11:31+00:00","mainEntityOfPage":{"@id":"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/"},"wordCount":6,"publisher":{"@id":"https:\/\/www.crestboz.co.jp\/techblog\/#organization"},"articleSection":["Python"],"inLanguage":"ja"},{"@type":"WebPage","@id":"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/","url":"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/","name":"Python\u306edatetime\u578b\u306e\u30c7\u30fc\u30bf\u3067\u5f15\u304d\u7b97\u3092\u884c\u306a\u3046 - \u30af\u30ec\u30b9\u30c8\u30dc\u30a6\u30ba::\u6280\u8853\u8005\u30d6\u30ed\u30b0","isPartOf":{"@id":"https:\/\/www.crestboz.co.jp\/techblog\/#website"},"datePublished":"2014-12-18T02:17:57+00:00","dateModified":"2016-09-17T08:11:31+00:00","breadcrumb":{"@id":"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.crestboz.co.jp\/techblog\/archives\/117\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u30db\u30fc\u30e0","item":"https:\/\/www.crestboz.co.jp\/techblog\/"},{"@type":"ListItem","position":2,"name":"Python\u306edatetime\u578b\u306e\u30c7\u30fc\u30bf\u3067\u5f15\u304d\u7b97\u3092\u884c\u306a\u3046"}]},{"@type":"WebSite","@id":"https:\/\/www.crestboz.co.jp\/techblog\/#website","url":"https:\/\/www.crestboz.co.jp\/techblog\/","name":"\u30af\u30ec\u30b9\u30c8\u30dc\u30a6\u30ba::\u6280\u8853\u8005\u30d6\u30ed\u30b0","description":"IT\u95a2\u9023\u306e\u6280\u8853\u7684\u306a\u3053\u3068\u306b\u95a2\u3057\u3066\u8abf\u67fb\u3057\u305f\u3053\u3068\u306a\u3069\u3092\u516c\u958b\u3059\u308b\u30d6\u30ed\u30b0\u3067\u3059","publisher":{"@id":"https:\/\/www.crestboz.co.jp\/techblog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.crestboz.co.jp\/techblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ja"},{"@type":"Organization","@id":"https:\/\/www.crestboz.co.jp\/techblog\/#organization","name":"\u30af\u30ec\u30b9\u30c8\u30dc\u30a6\u30ba\u682a\u5f0f\u4f1a\u793e","url":"https:\/\/www.crestboz.co.jp\/techblog\/","logo":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.crestboz.co.jp\/techblog\/#\/schema\/logo\/image\/","url":"https:\/\/www.crestboz.co.jp\/techblog\/wp-content\/uploads\/2019\/12\/robot.png","contentUrl":"https:\/\/www.crestboz.co.jp\/techblog\/wp-content\/uploads\/2019\/12\/robot.png","width":387,"height":387,"caption":"\u30af\u30ec\u30b9\u30c8\u30dc\u30a6\u30ba\u682a\u5f0f\u4f1a\u793e"},"image":{"@id":"https:\/\/www.crestboz.co.jp\/techblog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/crestboz","https:\/\/x.com\/crestboz"]},{"@type":"Person","@id":"","url":"https:\/\/www.crestboz.co.jp\/techblog\/archives\/author\/"}]}},"_links":{"self":[{"href":"https:\/\/www.crestboz.co.jp\/techblog\/wp-json\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.crestboz.co.jp\/techblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.crestboz.co.jp\/techblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.crestboz.co.jp\/techblog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.crestboz.co.jp\/techblog\/wp-json\/wp\/v2\/comments?post=117"}],"version-history":[{"count":1,"href":"https:\/\/www.crestboz.co.jp\/techblog\/wp-json\/wp\/v2\/posts\/117\/revisions"}],"predecessor-version":[{"id":120,"href":"https:\/\/www.crestboz.co.jp\/techblog\/wp-json\/wp\/v2\/posts\/117\/revisions\/120"}],"wp:attachment":[{"href":"https:\/\/www.crestboz.co.jp\/techblog\/wp-json\/wp\/v2\/media?parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.crestboz.co.jp\/techblog\/wp-json\/wp\/v2\/categories?post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.crestboz.co.jp\/techblog\/wp-json\/wp\/v2\/tags?post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}