M
M
Mem_ory2021-12-19 14:34:32
Python
Mem_ory, 2021-12-19 14:34:32

How to display the current value of minutes and hours?

import datetime
print(datetime.date.today().month,
      "/", datetime.date.today().day,
      "/", datetime.date.today().year,
      "_", datetime.time().hour,
      ":", datetime.time().minute)

When activated, "12 / 19 / 2021 _ 0 : 0" is displayed.
I guess that I forgot about some now attribute, but I don't know where and how to enter it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Kitaev, 2021-12-19
@deliro

https://docs.python.org/3/library/datetime.html#da...

N
nolouds, 2021-12-19
@nolouds

It's all right? You can replace the "-" characters with "/" as you prefer.

import datetime
now = datetime.datetime.now()
print (now.strftime("%Y-%m-%d %H:%M:%S"))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question