You can get the date for the first day of the current century in Python by using the datetime module and performing some simple calculations. Here's an example code snippet:
main.py275 chars13 lines
This code first gets the current year using the datetime module. It then calculates the start year of the current century by dividing the current year by 100, rounding down, and then multiplying by 100. For example, if the current year is 2021, the start year of the current century is 2000.
Finally, the code creates a date object for the first day of the current century by passing in the start year, 1 for January, and 1 for the first day of the month. The output will be in the format "YYYY-MM-DD".
gistlibby LogSnag