<h1>Displaying Current Date and Time Using Datetime Module</h1>

Write a Python program that uses the datetime module to display the current date and time. Return the current date and time.

Example:

Input: None
Output: Current date and time

Use the datetime function from the datetime module.

import datetime

def get_current_datetime():
    return datetime.datetime.now()

# Test the function
print(get_current_datetime())  # Output: Current date and time
print(get_current_datetime())  # Output: Current date and time

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!