Closed icaoberg closed 4 months ago
@Az1z4 if you want to include the hour you could use
| Method | Code | Output Format |
|--------------------------------|-----------------------------------------------------------------------------------------------|-------------------|
| Using `datetime` module | ```python from datetime import datetime today = datetime.now() print(today)``` | `YYYY-MM-DD HH:MM:SS` |
| Using `datetime` with formatting | ```python from datetime import datetime today = datetime.now().strftime('%Y-%m-%d %H:%M:%S')``` | `YYYY-MM-DD HH:MM:SS` |
| Using `time` module | ```python import time today = time.strftime('%Y-%m-%d %H:%M:%S')``` | `YYYY-MM-DD HH:MM:SS` |
| Using `pandas` | ```python import pandas as pd today = pd.Timestamp.now().strftime('%Y-%m-%d %H:%M:%S')``` | `YYYY-MM-DD HH:MM:SS` |
https://github.com/icaoberg/cs-scholars2024-fair/blob/0d757b6781ac29be209857d395b4b48737d9e56a/streamlit_app.py#L17
Modify this line to reflect today's date programmatically.
You can
datetime
modulefrom datetime import date today = date.today()
|YYYY-MM-DD
datetime
with formattingfrom datetime import datetime today = datetime.now().strftime('%Y-%m-%d')
|YYYY-MM-DD
time
moduleimport time today = time.strftime('%Y-%m-%d')
|YYYY-MM-DD
pandas
import pandas as pd today = pd.Timestamp.now().strftime('%Y-%m-%d')
|YYYY-MM-DD