Skip to content

Commit fbe96c8

Browse files
Add datetime to Python language docs.
1 parent ff14bd1 commit fbe96c8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/python/python-language.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,22 @@ _Further Reading_
19211921

19221922
Python comes with 100s of built-in modules. We'll briefly cover a few that are used often at CWHQ in this section. See the _Further Reading_ section for details on where you can browse all of Python's built-in modules.
19231923

1924+
#### datetime
1925+
1926+
The `datetime` module is used to work with times and dates.
1927+
1928+
##### `Getting a today's date`
1929+
1930+
You use the `date.today()` method to get today's date in the form **YYYY-MM-DD**:
1931+
1932+
```python
1933+
from datetime import date
1934+
1935+
# Let's pretend it's February 10, 2023 for this example
1936+
current_date = date.today()
1937+
print(current_date) # 2023-02-10
1938+
```
1939+
19241940
#### random
19251941

19261942
The `random` module is used to add randomness to your programs.

0 commit comments

Comments
 (0)