Python Forum
Help needed in finding a library for this project
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help needed in finding a library for this project
#1
Hey everyone, I just got an idea to make a automation project but I didn't know which library it needed. The automation project involves time, which means that the library should be able to detect time. For example this code should be able to check if it is 5PM or not in my PC. Could someone please suggest a library which can do this. I tried searching online for the library but I couldn't find any. Thank you
Reply
#2
Happy Christmas!

You need datetime! Look up the docs for all the %letter parameters.

from datetime import datetime

now = datetime.now()
print(now.strftime('Hour (00-11)          : %I'))
print(now.strftime('AM/PM                 : %p'))
print(now.strftime('%I%p'))
hour = now.strftime('%I%p')
if hour == '05PM':
    do something
PythonEnthusiast1729 likes this post
Reply
#3
Pedroski55 Wrote:You need datetime! Look up the docs for all the %letter parameters.
Hey Pedroski55, Thanks and Happy Christmas to you as well!. Snowman

Now finally thanks to you, I can learn more about this library and get started with my project
Reply
#4
FYI: you may also want to take a look at Doug Hellmann's PYMOTW3 on datetime here.
This is an excellent write-up with many examples.
Reply
#5
(Dec-25-2023, 04:25 PM)Larz60+ Wrote: FYI: you may also want to take a look at Doug Hellmann's PYMOTW3 on datetime here.
This is an excellent write-up with many examples.

Hey, @Larz60+, I just went through the document and it is actually very informative. I will make sure to learn the library from this document. Thanks!
Reply
#6
I was just reading through the document and I couldn't find how to display the time now
They have showed us how to display todays date but not how to display the time at any exact moment
Could you please help me figure out how to display the time of any exact moment?
Thank you!
Reply
#7
On the mentioned website:
print('Now    :', datetime.datetime.now())
Reply
#8
(Dec-26-2023, 04:39 PM)deanhystad Wrote: On the mentioned website:
print('Now    :', datetime.datetime.now())

Oh ok, This is how you do it

Thank you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Music Help with: Audiobook Library/Copier Project eleven43 0 489 Sep-14-2023, 04:17 PM
Last Post: eleven43
  Problem with importing python-telegram library into the project gandonio 1 1,581 Nov-01-2022, 02:19 AM
Last Post: deanhystad
  Join the Python Standard Library to my project sylas 1 2,210 May-16-2018, 05:59 AM
Last Post: buran
  Library Program Prison Project lewashby 9 6,285 Jul-13-2017, 05:25 AM
Last Post: Larz60+
  PyInstaller, how to create library folder instead of library.zip file ? harun2525 2 4,816 May-06-2017, 11:29 AM
Last Post: harun2525

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020