VOOZH about

URL: https://www.digitalocean.com/community/tutorials/python-current-date-time

⇱ Python Current Date Time | DigitalOcean


Python Current Date Time

Published on August 3, 2022
👁 Python Current Date Time

We can use Python datetime module to get the current date and time of the local system.

from datetime import datetime

# Current date time in local system
print(datetime.now())

Output: 2018-09-12 14:17:56.456080

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author

Java and Python Developer for 20+ years, Open Source Enthusiast, Founder of https://www.askpython.com/, https://www.linuxfordevices.com/, and JournalDev.com (acquired by DigitalOcean). Passionate about writing technical articles and sharing knowledge with others. Love Java, Python, Unix and related technologies. Follow my X @PankajWebDev

Category:
Tags:
While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.

Still looking for an answer?

Was this helpful?

Hello. I want to make print current time like mysql’s datetime format. example 2021-08-27 18:10:11 How to make it without 3rd party libraries?

- yolu

Uups, I need to setup something because after the “succesfull” installation of pytz and pendulum I get the same error: ModuleNotFoundError: No module named ‘pytz’ or ModuleNotFoundError: No module named ‘pendulum’ but when I try to run the install again I got the message “Requirement already satisfied: python-dateutil=2.6 in /usr/lib/python3/dist-packages (from pendulum) (2.7.3)”, similar with pytz module. Please give me a tip for fixing this. I have lubuntu 20.04 and Python 3.8.10 (default, Sep 28 2021, 16:10:42) [GCC 9.3.0] on linux

- Juan Manuel Carrillo Campos

👁 Creative Commons
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
  • Deploy on DigitalOcean

    Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and AI-native businesses

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

© 2026 DigitalOcean, LLC.Sitemap.
Dark mode is coming soon.