| import streamlit as st |
| from datetime import datetime |
| from datetime import datetime, date |
|
|
| |
| |
| st.markdown(f""" |
| <style> |
| /* Set the background image for the entire app */ |
| .stApp {{ |
| background-color:rgba(149, 201, 126,0.2); |
| background-repeat: no-repeat; |
| background-attachment: fixed; |
| background-position: center; |
| }} |
| |
| </style> |
| """, unsafe_allow_html=True) |
|
|
| st.title("Age Calculator") |
|
|
| |
| dob = st.date_input("Date of Birth",min_value=date(1900, 1, 1)) |
|
|
| |
| today = st.date_input("Today's Date", datetime.today()) |
|
|
| |
| if dob and today: |
| |
| if today >= dob: |
| age = today.year - dob.year - ((today.month, today.day) < (dob.month, dob.day)) |
| st.write(f"**Your age is:** {age} **years**") |
| else: |
| st.write("Today's date cannot be before the date of birth.") |
|
|