Untitled

mail@pastecode.io avatar
unknown
plain_text
22 days ago
614 B
1
Indexable
Never
from datetime import datetime

def find_day_of_week(date_string):
    # Parse the date string into a datetime object
    date_obj = datetime.strptime(date_string, '%Y-%m-%d')
    
    # Get the day of the week as an integer (Monday is 0 and Sunday is 6)
    day_of_week = date_obj.weekday()
    
    # List of days of the week
    days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
    
    # Return the day of the week as a string
    return days[day_of_week]

# Example usage:
date_string = '2024-07-02'
print(find_day_of_week(date_string))  # Output: Monday
Leave a Comment