Friday, September 5, 2025
HomeLanguagesPython Tweepy – Getting the time when a user was created

Python Tweepy – Getting the time when a user was created

In this article we will see how we can get the time and date when a user created their Twitter account. The created_at attribute provides us with a datetime object denoting the exact time when the user account was created.

Identifying the date when a user was created in the GUI :

In the above mentioned profile the user was created on July 2009.

In order to get the date and time when the user was created, we have to do the following :

  1. Identify the user ID or the screen name of the profile.
  2. Get the User object of the profile using the get_user() method with the user ID or the screen name.
  3. From this object, fetch the created_at attribute present in it.

Example 1: Consider the following profile :

We will use the user ID to fetch the user. The user ID of the above mentioned profile is 57741058.




# import the module
import tweepy
  
# assign the values accordingly
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
  
# authorization of consumer key and consumer secret
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
  
# set access to user's access key and access secret 
auth.set_access_token(access_token, access_token_secret)
  
# calling the api 
api = tweepy.API(auth)
  
# the ID of the user
id = 57741058
  
# fetching the user
user = api.get_user(id)
  
# fetching the create_at attribute
created_at = user.created_at
  
print("The user was created on : " + str(created_at))


Output :

The user was created on : 2009-07-17 20:02:09

Example 2: Consider the following profile :

We will use the screen name to fetch the user. The screen name of the above mentioned profile is PracticeGfG.




# the screen name of the user
screen_name = "PracticeGfG"
  
# fetching the user
user = api.get_user(screen_name)
  
# fetching the create_at attribute
created_at = user.created_at
  
print("The user was created on : " + str(created_at))


Output :

The user was created on : 2016-01-23 12:03:47
Last Updated :
18 Jun, 2020
Like Article
Save Article

<!–

–>

Similar Reads
Related Tutorials
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32265 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11864 POSTS0 COMMENTS
Shaida Kate Naidoo
6752 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6703 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS