The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Create a personalized birthday reminder tool

Here’s a simple personalized birthday reminder tool built with Python. It allows users to add birthdays, save them, and get reminders when a birthday is approaching.

python
import datetime import json import os BIRTHDAY_FILE = "birthdays.json" def load_birthdays(): if not os.path.exists(BIRTHDAY_FILE): return {} with open(BIRTHDAY_FILE, 'r') as file: return json.load(file) def save_birthdays(birthdays): with open(BIRTHDAY_FILE, 'w') as file: json.dump(birthdays, file, indent=4) def add_birthday(name, date_str): birthdays = load_birthdays() try: date = datetime.datetime.strptime(date_str, "%Y-%m-%d").date() birthdays[name] = date_str save_birthdays(birthdays) print(f"Birthday for {name} added.") except ValueError: print("Invalid date format. Use YYYY-MM-DD.") def show_upcoming_birthdays(days_ahead=7): today = datetime.date.today() upcoming = [] birthdays = load_birthdays() for name, date_str in birthdays.items(): bday = datetime.datetime.strptime(date_str, "%Y-%m-%d").date() next_birthday = bday.replace(year=today.year) if next_birthday < today: next_birthday = next_birthday.replace(year=today.year + 1) delta = (next_birthday - today).days if 0 <= delta <= days_ahead: upcoming.append((name, next_birthday, delta)) if upcoming: print("Upcoming Birthdays:") for name, bday, delta in sorted(upcoming, key=lambda x: x[2]): print(f"{name} - {bday.strftime('%B %d')} (in {delta} days)") else: print("No upcoming birthdays.") def main(): while True: print("nBirthday Reminder Tool") print("1. Add a birthday") print("2. Show upcoming birthdays") print("3. Exit") choice = input("Select an option: ") if choice == '1': name = input("Enter name: ") date = input("Enter birthday (YYYY-MM-DD): ") add_birthday(name, date) elif choice == '2': show_upcoming_birthdays() elif choice == '3': print("Goodbye!") break else: print("Invalid choice. Try again.") if __name__ == "__main__": main()

Features:

  • Stores birthdays in a local JSON file

  • Checks and lists birthdays coming up in the next 7 days

  • Simple CLI for adding and viewing birthdays

How to Use:

  1. Save the code to a .py file (e.g., birthday_reminder.py).

  2. Run it using Python: python birthday_reminder.py.

  3. Use the menu to add birthdays or view reminders.

Let me know if you want a web version or integration with email/SMS alerts.

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About