0
votes

I'm querying a timestamp column from datastax php diver for cassandra

select name , x_date from table;

The result is returned in json format

name: "name"
x_date: {type: {name: "timestamp"}, seconds: 1561645740, microseconds: 0}

I want to get simple string representation of date formatted like YYYY-mm-dd as it appears on cql client not json.

I've tried TODATE function but same result is returned.

1

1 Answers

1
votes

After some search i found that class Cassandra\Timestamp included in datastax driver for php has a function toDateTime() that convert the json into php datetime format

 $datetime = x_date->toDateTime();

then i used format() to get my date formatted

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