Postgresql function to convert a tweet id to the time it was created in milliseconds:
CREATE OR REPLACE FUNCTION tweet_id_to_timestamp(b1 bigint) RETURNS timestamptz AS $$
BEGIN
RETURN to_timestamp(((b1 >> 22) + 1288834974657)::float / 1000);
END; $$
LANGUAGE PLPGSQL;
Conversation
Replying to
(Using the previous tweet id)
twitter=# select tweet_id_to_timestamp(1175290160151486464);
tweet_id_to_timestamp
----------------------------
2019-09-21 06:06:24.672+00
(1 row)
3
Replying to
Does this function only work for IDs after a certain time? A similar effort of mine would break for anything older than 2015 maybe?
1
1
Show replies

