0

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 ?

giampaolo
  • 6,906
  • 5
  • 45
  • 73
aacanakin
  • 2,844
  • 4
  • 25
  • 42

1 Answers1

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
  • 1
    You 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