I'm trying to get date from timeuuid without calling dateOf(id)
function in cqlsh.
So, is there any function in phpcassa that can convert timeuuid to date ?
Asked
Active
Viewed 1,121 times
0
-
Possible duplicate: http://stackoverflow.com/questions/9638198/getting-value-from-a-key-type-timeuuid-in-cassandra-php – Lyuben Todorov Aug 01 '13 at 13:06
-
Well, in the latest version, there's no `CassandraUtil` but there exist `UUID::import($timeuuid)` – aacanakin Aug 01 '13 at 13:54
1 Answers
2
You can use the $time
attribute of \phpcassa\UUID
objects to get a unix timestamp, like so:
$timeuuid = UUID::uuid1();
echo "timestamp: $timeuuid->time";
From there it's easy to make other date and time objects.

Tyler Hobbs
- 6,872
- 24
- 31
-
Well, I try to convert an existing string timeuuid to `uuid1`. i.e `$timeuuid = "0e6f9df0-fb40-11e2-8bbc-ef32f0e43a97"`. I'm trying to get timestamp out of it. How can I do that ? – aacanakin Aug 02 '13 at 07:02
-
1You need to create a UUID object from that string first by doing `$timeuuid = UUID::import("0e6f9df0-fb40-11e2-8bbc-ef32f0e43a97");` – Tyler Hobbs Aug 02 '13 at 16:06