I use Cassandra DB and Helenus module for nodejs to operate with this. I have some rows which contains TimeUUID columns. How to get timestamp from TimeUUID in javascript?
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- google-drive can't get push notifications
- How to reimport module with ES6 import
- What version of Java does Cassandra 3 require
- Why is `node.js` dying when called from inside pyt
相关文章
- node连接远程oracle报错
- Cassandra Read a negative frame size
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- Transactionally writing files in Node.js
- Log to node console or debug during webpack build
node-uuid module for nodejs contains method for convert uuid v1 to timestamp
Commit with function for extract msecs from uuid v1
this lib ( UUID_to_Date ) is very simple and fast!! only used native String function. maybe this Javascript API can help you to convert the UUID to date format, Javascript is simple language and this simple code can help to writing API for every language.
this API convert UUID v1 to sec from 1970-01-01
all of you need:
Example:
You can use the
unixTimestampOf
ordateOf
functions in CQL3, or you can do it yourself, the hard way:The time is encoded into the top 64 bits of the UUID, but it's interleaved with some other pieces, so it's not super straight forward to extract a time.
If
n
is the integer representation of theTimeUUID
then you can extract the UNIX epoch like this:this code is from my Ruby CQL3 driver, cql-rb, and can be found in full here: https://github.com/iconara/cql-rb/blob/master/lib/cql/time_uuid.rb
I used this resource: http://www.famkruithof.net/guid-uuid-timebased.html, and the RFC to implement that code.
Use
uuid-time
module.I asked maintainers of uuid module here https://github.com/kelektiv/node-uuid/issues/297 and they pointed me to the uuid-time module https://www.npmjs.com/package/uuid-time