Sunny Liu
Sunny Liu

Reputation: 79

Automate Generate Dates in Jupyter Notebook Markdown

I want to have an "updated date" in my Jupyter Notebook markdown. Can someone tells me if I could have that date populated automatically? If so, how?

Thank you in advance!

Upvotes: 5

Views: 3620

Answers (1)

codeananda
codeananda

Reputation: 1310

You can use the IPython.display module in combination with datetime.

from datetime import datetime
from IPython.display import display, Markdown

todays_date = str(datetime.now().date())

display(Markdown(f'# Report for Week {todays_date}'))

Answer adapted from answers to the question: How to programmatically generate markdown output in Jupyter notebooks?

Upvotes: 2

Related Questions