Languages
[Edit]
EN

Python - get current datetime

0 points
Created by:
Gaia-Kirby
720

In this article, we would like to show you how get current datetime in Python.

To work with date objects, you need to import the datetime module using:

 

1. Get current datetime

Edit

In this example, we use datetime.datetime.now() to get the current datetime.

Output:

2. Get year / month / day

Edit

In this example, we get year, month and day from current datetime.

Example output:

3. Get hour / minute / second

Edit

In this example, we get hour, minute and second from current datetime.

Example output:

See also

Edit
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join