Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何获得cassandra时间戳列的字符串表示形式?_Cassandra_Cql_Datastax Php Driver - Fatal编程技术网

如何获得cassandra时间戳列的字符串表示形式?

如何获得cassandra时间戳列的字符串表示形式?,cassandra,cql,datastax-php-driver,Cassandra,Cql,Datastax Php Driver,我正在从datastax php diver查询cassandra的时间戳列 select name , x_date from table; 结果以json格式返回 name: "name" x_date: {type: {name: "timestamp"}, seconds: 1561645740, microseconds: 0} 我想得到日期的简单字符串表示形式,格式类似于YYYY-mm-dd,因为它出现在cql客户机上,而不是json上 我尝试了TODATE函数,但返回了相同的结

我正在从datastax php diver查询cassandra的时间戳列

select name , x_date from table;
结果以json格式返回

name: "name"
x_date: {type: {name: "timestamp"}, seconds: 1561645740, microseconds: 0}
我想得到日期的简单字符串表示形式,格式类似于YYYY-mm-dd,因为它出现在cql客户机上,而不是json上


我尝试了TODATE函数,但返回了相同的结果。

经过一些搜索后,我发现datastax driver for php中包含的Cassandra\Timestamp类有一个函数toDateTime,该函数将json转换为php日期时间格式

 $datetime = x_date->toDateTime();
然后我用格式化来格式化我的日期

 $myPhpDate = $datetime->format('d/m/Y H:i:s');