Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

日付を取得できるようにした #28

Merged
merged 1 commit into from Jul 17, 2020

Conversation

okazy
Copy link
Contributor

@okazy okazy commented Jul 13, 2020

close #27

DateTime を扱う DateTimeType を独自に実装した。

日付のフォーマットは DateTime::ATOM = "Y-m-d\TH:i:sP" とした
https://www.php.net/manual/ja/class.datetimeinterface.php#datetime.constants.atom

DateTimeInterface::ATOM
Atom (例: 2005-08-15T15:52:01+00:00)

DateTimeInterface::RFC3339_EXTENDED でミリ秒まで返せるが、そもそもDBでミリ秒まで管理できていないので 000 となってしまうので対応していない。

▼参考にしたIssue
webonyx/graphql-php#228 (comment)

▼参考にしたドキュメント
https://webonyx.github.io/graphql-php/type-system/scalar-types/

request

query getOrders {
  products {
    id
    create_date
    update_date
  }
}

responce

{
  "data": {
    "products": [
      {
        "id": "5",
        "create_date": "2020-07-13T17:40:50+09:00",
        "update_date": "2020-07-13T17:42:18+09:00"
      },
      {
        "id": "4",
        "create_date": "2020-07-07T16:26:18+09:00",
        "update_date": "2020-07-07T16:26:18+09:00"
      },
      {
        "id": "3",
        "create_date": "2020-07-07T15:27:17+09:00",
        "update_date": "2020-07-07T15:27:17+09:00"
      },
      {
        "id": "1",
        "create_date": "2018-09-28T19:14:52+09:00",
        "update_date": "2018-09-28T19:14:52+09:00"
      },
      {
        "id": "2",
        "create_date": "2018-09-28T19:14:52+09:00",
        "update_date": "2018-09-28T19:14:52+09:00"
      }
    ]
  }
}

@okazy okazy added the enhancement New feature or request label Jul 13, 2020
@okazy okazy added this to the 1.0 milestone Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DateTime型の取得
2 participants