GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • w3resource
  • Front End
  • HTML
  • CSS
  • JavaScript
  • HTML5
  • Schema.org
  • php.js
  • Twitter Bootstrap
  • Responsive Web Design tutorial
  • Zurb Foundation 3 tutorials
  • Pure CSS
  • HTML5 Canvas
  • JavaScript Course

This view

  • Original page
  • New address

GeezerVison is showing www.w3resource.com — Python: System time print Python - w3resource

Python: System time print Python

Last update on May 17 2025 05:43:39 (UTC/GMT +8 hours)


Get System Time

Write a Python program to get system time.

Note : The system time is important for debugging, network information, random number seeds, or something as simple as program performance.

Pictorial Presentation:

Get the system time


Sample Solution-1:

Python Code:

# Import the 'time' module to work with time-related functions.
import time

# Print an empty line for formatting.
print()

# Get and print the current time using 'time.ctime()'.
print(time.ctime())

# Print an empty line for formatting.
print()

Sample Output:

Thu Apr 20 18:25:06 2017

Sample Solution-2:

Python Code:

import datetime
print(datetime.datetime.now())

Sample Output:

2021-06-04 08:40:11.391443

For more Practice: Solve these Related Problems:

  • Write a Python program to get the system time in 12-hour and 24-hour formats.
  • Write a Python program to measure the execution time of a specific function.
  • Write a Python program to synchronize the system clock with an external time source.
  • Write a Python program to get the time elapsed between two function calls.

Go to:

  • Python Basic Exercises Home ↩
  • Python Exercises Home ↩

Previous: Write a Python program to list the special variables used within the language.
Next: Write a Python program to clear the screen or terminal.

Python Code Editor:

 

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.


  • Daily Coding Challenges & Projects
  • Weekly Trends and Language Statistics



You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.