0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

date_parse_from_format 日時フォーマット (ISO 8601 RSS1.0) チェックメモ

Posted at

2021-08-11T18:19:04+09:00
YYYY-MM-DDThh:mm:ss+09:00
のタイムゾーンありきのフォーマットチェックに詰まったのでメモ

以前は

strptime($val, '%Y-%m-%dT%H:%M:%S%z')

で日時をチェックしていたがOSによって挙動が違うのでdate_parse_from_formatに書き換えることにした
APIから受け取るフォーマットが2021-08-11T18:19:04+09:00なので

date_parse_from_format('Y-m-d\TH:i:sO', '2021-08-11T18:19:04+09:00')

ってやればエラーを検出せずにすむ
Y-m-d\TH:i:s\+09:00※一応これでも大丈夫
こういう調査って地味に時間かかるの備忘録して参考になれば~

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?