Get current date and time in Python


/ Published in: Python
Save to your folder(s)

Always gives me perfect date.

Sample Output

Current Day is: 1
Current Month is: 2
Current Year is: 2020
Current Hour is: 17
Current Minute is: 3
Current Second is: 8
Current Microsecond is: 556483


Copy this code and paste it in your HTML
  1. from datetime import datetime
  2.  
  3. now = datetime.now()
  4. print("Current Day is:", now.day)
  5. print("Current Month is:", now.month)
  6. print("Current Year is:", now.year)
  7. print("Current Hour is:", now.hour)
  8. print("Current Minute is:", now.minute)
  9. print("Current Second is:", now.second)
  10. print("Current Microsecond is:", now.microsecond)

URL: https://speedysense.com/get-current-date-time-python/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.