HappiomHappiom
  • Self-Improvement
  • Relationship
  • AI for Life
  • Apps
  • Tech
  • More
    • Online Diary
    • Glossary
  • Learn
    • Book
    • >> Soft Skills
    • Time Management
    • >> Tech Skills
    • R
    • Linux
    • Python
  • Our Apps
    • Download Diary App
    • Write Your First Diary
    • Login to Online Diary App
    • 100K+ Famous Quotes Site
  • Resources
    • Self-Improvement Guide
      • 21-Days to Self-Improvement
      • Creating a Habit
      • Learn Life Experiences
      • Easily Prioritizing Tasks
      • Learning from Mistakes
      • Doing Regular Exercises
      • Setting Priority for Success
      • Avoiding Common Mistakes
      • Eating Healthy Food Regularly
    • Journaling Guide
      • Online Diary
      • Best Diary Apps
      • Diary Writing Ideas
      • Diary Writing Topics
      • Avoid Writing in Diary
      • Diary Writing as Hobby
      • Reasons to Write a Diary
      • Types of Feelings In Diary
      • Improve Diary Writing Skills
  • Self-Improvement
  • Relationship
  • AI for Life
  • Apps
  • Tech
  • More
    • Online Diary
    • Glossary
  • Learn
    • Book
    • >> Soft Skills
    • Time Management
    • >> Tech Skills
    • R
    • Linux
    • Python
  • Our Apps
    • Download Diary App
    • Write Your First Diary
    • Login to Online Diary App
    • 100K+ Famous Quotes Site
  • Resources
    • Self-Improvement Guide
      • 21-Days to Self-Improvement
      • Creating a Habit
      • Learn Life Experiences
      • Easily Prioritizing Tasks
      • Learning from Mistakes
      • Doing Regular Exercises
      • Setting Priority for Success
      • Avoiding Common Mistakes
      • Eating Healthy Food Regularly
    • Journaling Guide
      • Online Diary
      • Best Diary Apps
      • Diary Writing Ideas
      • Diary Writing Topics
      • Avoid Writing in Diary
      • Diary Writing as Hobby
      • Reasons to Write a Diary
      • Types of Feelings In Diary
      • Improve Diary Writing Skills
Expand All Collapse All
  • Python Examples
    • Basic Syntax
      • Python Example Code to Concat 2 Numbers
      • Python Example Code to Concat N Strings
      • Python Code to Find Perimeter of a Circle
      • Python Code to Convert CSV file to Parquet format
      • Python Code to Get Current Day of Week
      • Python Code to Convert Binary String to Decimal Number Vice versa
      • Python Code to Find Difference Between 2 Strings
      • Python Example Code to Remove Duplicates from a List
      • Python Example Code to Calculate Height of Triangle
      • Python Code to Generate Complex Random Password
    • File Handling
      • Python Code to Write & Read Key Value Pair in File
      • In Python File is Not Opening (How to Fix)
      • Python Code to Read Specific Line from a File
      • Python Code to Clear Contents of a File
      • Python Code to Count and List Files in a Directory
    • Modules and Libraries
      • Python Code for Automation using BDD
      • Python Code to Load .SO File (and Invoke a Function)
    • Object-Oriented Programming
      • Python Code to Create a Class with Attributes
      • Python Code to Define Methods in a Class
    • Python Example Code to Check Internet Connection
    • Example Python Code to Send an Email
    • Python Code to Fetch Data from an API (e.g., OpenWeatherMap)
    • Example Python Code to Extract Text from PDF
    • Python Code to Perform Web Scraping (e.g., Scraping Wikipedia)
    • Example Python Code to Plot Data Using Matplotlib
    • Python Code to Perform Data Analysis with Pandas
    • Example Python Code to Train a Simple Machine Learning Model (e.g., Linear Regression)
    • Python Code to Handle User Authentication in Flask
    • Example Python Code to interact with databases using libraries like SQLAlchemy

Python Code to Get Current Day of Week

In Python, there are multiple approaches to obtain the current day of the week, each offering its own advantages.

  1. Using the weekday() method from the datetime module, which returns the day of the week as an integer, allowing for easy mapping to day names.
  2. Another method utilizes the strftime() method, enabling direct formatting of a datetime object into a string representation of the day of the week.

While the former provides flexibility in handling day names through integer values, the latter offers a more concise solution by directly formatting the date object.

Method 1 – Using datetime module

You can use the datetime module in Python to get the current day of the week.

Let’s see a simple code snippet to achieve that.

import datetime

# Get the current date
current_date = datetime.datetime.now()

# Get the day of the week (0 = Monday, 1 = Tuesday, ..., 6 = Sunday)
day_of_week = current_date.weekday()

# Convert the day of the week to a string
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
current_day_of_week = days[day_of_week]

print("Today is:", current_day_of_week)

Now I’ll explain the above code in detail:

  • Import the datetime module to work with dates and times.
  • Get the current date and time using datetime.datetime.now().
  • Use the weekday() method to get the day of the week as an integer (0 for Monday, 1 for Tuesday, etc.).
  • Create a list of day names.
  • Retrieve the day name corresponding to the integer obtained in step 3.
  • Print the current day of the week.

Method 2 – Using strftime() method

Let’s explore another method to get the current day of the week is by using the strftime() method available in the datetime module. This method allows you to format a datetime object into a string representation according to a specified format.

You can use the %A format specifier to retrieve the full name of the day of the week.

The example code is below:

import datetime

# Get the current date
current_date = datetime.datetime.now()

# Format the current date to retrieve the full name of the day of the week
current_day_of_week = current_date.strftime("%A")

print("Today is:", current_day_of_week)

Let me summarize the key points from the above example.

  • Import the datetime module to work with dates and times.
  • Get the current date and time using datetime.datetime.now().
  • Use the strftime() method to format the current_date object into a string representation.
  • Pass “%A” as the format specifier to strftime(). %A represents the full name of the day of the week.
  • Store the formatted string (the full name of the day of the week) in the variable current_day_of_week.
  • Print the current day of the week.

This method directly formats the date object into the desired string representation, eliminating the need for additional logic to map integers to day names as in the previous method.

It’s easy to understand.

Related Articles
  • Python Example Code to Calculate Height of Triangle
  • Python Example Code to Remove Duplicates from a List
  • Example Python Code to interact with databases using libraries like SQLAlchemy
  • Python Code to Handle User Authentication in Flask
  • Example Python Code to Train a Simple Machine Learning Model (e.g., Linear Regression)
  • Python Code to Perform Data Analysis with Pandas

No luck finding what you need? Contact Us

Previously
Python Code to Convert CSV file to Parquet format
Up Next
Python Code to Convert Binary String to Decimal Number Vice versa
  • About Us
  • Contact Us
  • Archive
  • Hindi
  • Tamil
  • Telugu
  • Marathi
  • Gujarati
  • Malayalam
  • Kannada
  • Privacy Policy
  • Copyright 2026 Happiom. All Rights Reserved.