teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

修正

2021/01/10 10:12

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -22,4 +22,17 @@
22
22
  int(exec_date[20:-1]),
23
23
  ) # 2021 1 5 12 6 1 0
24
24
 
25
+ ```
26
+
27
+ ----
28
+
29
+ ちなみに pandas を使うのであれば、このようなことをしなくても以下のように日本時間にできます。
30
+
31
+ ```python
32
+ import pandas as pd
33
+
34
+ exec_date = "2021-01-05T12:06:01.000Z"
35
+
36
+ time_jp = pd.Timestamp(exec_date).tz_convert("Asia/Tokyo")
37
+ print(time_jp)
25
38
  ```

1

修正

2021/01/10 10:12

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -1,6 +1,6 @@
1
1
  > datetime.detatimeの箇所では何をしているのでしょうか?
2
2
 
3
- `exec_date` は日付を表すただの文字列なので、これをスライスで分解し、int 型に変換したのち、`datetime.datetime()` のコンストラクタ引数に渡して、datetime.datetime を作成しています。
3
+ `exec_date` は日付を表すただの文字列なので、これをスライスで分解し、int 型に変換したのち、`datetime.datetime` のコンストラクタ引数に渡して、datetime.datetime オブジェクトを作成しています。
4
4
 
5
5
  ```python
6
6
  class datetime.datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0)