Can a JSON object returned by PHP contain a date object

前端 未结 5 665
轻奢々
轻奢々 2020-12-20 11:36

Is there a way to create a JSON object in PHP that contains a javascript date object? Does json_encode automatically convert PHP\'s DateTime<

5条回答
  •  遥遥无期
    2020-12-20 12:30

    You could pass the date / time as a UNIX timestamp which is an integer, a natively supported data type in JSON. DateTime in PHP has a "getTimestamp()" function which will give you that value.

提交回复
热议问题