Convert Tweet Time Status to PHP for use in IF/ELSE Statement


For example this tweet -!/ps3blogdotnet/status/95178332215312385

How would I convert the time stamp (95178332215312385) to a usable format in PHP so I can do something like this:


// First I need to filter everything from the URL but the numbers somehow.. any ideas?
$tweet_time_strip =!/ps3blogdotnet/status/95178332215312385

$tweet_time = 95178332215312385;
$twitter_giveaway_start = 'today's date or whatever I want here';
if ( $tweet_time > $twitter_giveaway_start) {
// Do this
} else {
// Do this instead


Hi there,

The number yo think is a “tweet time” is actually the status identifier for the tweet – you can’t determine the time of the tweet strictly from that unique identifier. Instead, you’ll want to look for the created_at date field. This off-site article explains a bit more on consuming our date string in PHP:


Why is it impossible to determine tweet time from the id? The snowflake github page says that the first 41 bits are the “timestamp with custom epoch”, (appears to be 1288834974657L, or November 3rd 2010), which would imply the ts is recoverable.

However, the first 41 bits of 95178332215312385 are 1452306094594, which is 46 years! That’s in the future relative to unix time zero, let alone the custom epoch. Was my math wrong? Is it not possible to recover the time this way? We use a rotating collection of recently seen tweet ids in our app to minimize requests to the API, and it would be very helpful to determine approximate time/ordering from these.


Though you might be able to perform maths like this to a certain degree against the snowflake id, I recommend just considering it an opaque identifier. Using the field that represents the creation datetime of the object is recommended.