Spaces:
Sleeping
Sleeping
File size: 562 Bytes
02771a7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import streamlit as st
from datetime import datetime, date
st.set_page_config(page_title="Age Calculator", page_icon="๐")
st.title("๐ Age Calculator")
st.markdown("Enter your birthdate below to calculate your age:")
birthdate = st.date_input(
"Select your birthdate",
min_value=date(1900, 1, 1),
max_value=date.today()
)
if st.button("Calculate Age"):
today = date.today()
age = today.year - birthdate.year - (
(today.month, today.day) < (birthdate.month, birthdate.day)
)
st.success(f"Your age is: **{age}** years")
|