Skip to content

Instantly share code, notes, and snippets.

@fjcero
Created March 28, 2012 05:44
Show Gist options
  • Save fjcero/2223967 to your computer and use it in GitHub Desktop.
Save fjcero/2223967 to your computer and use it in GitHub Desktop.
Conversion de Twitter Status ID
Python
======
>>> status_id = int(184846323277770752)
>>> timestamp = (status_id >> 22)
>>> print timestamp
44070797748
>>> timestamp = (status_id >> 22) + 1288834974657
>>> print timestamp
1332905772405
>>> import time
>>> print time.ctime(timestamp/1000)
Wed Mar 28 00:36:12 2012
PHP
===
php > $status_id = '184846323277770752';
php > $timestamp = ($status_id >> 22);
php > echo $timestamp;
511
php > $timestamp = ($status_id >> 22) + '1288834974657';
php > echo $timestamp;
1288834975168
The integer value of var on success, or 0 on failure. Empty arrays return 0, non-empty arrays return 1.
The maximum value depends on the system. 32 bit systems have a maximum signed integer range of -2147483648 to 2147483647. So for example on such a system, intval('1000000000000') will return 2147483647. The maximum signed integer value for 64 bit systems is 9223372036854775807.
Strings will most likely return 0 although this depends on the leftmost characters of the string. The common rules of integer casting apply.
@fjcero
Copy link
Author

fjcero commented Mar 28, 2012

php > print PHP_INT_MAX;
2147483647

@fjcero
Copy link
Author

fjcero commented Mar 28, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment