About 51 results
Open links in new tab
  1. How do I get the current time in Python? - Stack Overflow

    Which version of Python was the original answer given in? Just typing datetime.datetime.now() in my Python 2.7 interactive console (IronPython hasn't updated yet) gives me the same behavior as the …

  2. Getting today's date in YYYY-MM-DD in Python? - Stack Overflow

    Sep 9, 2015 · Try not to use python built in functions and variables as local variables (ex: today, year, day). Also, the request from the user is to get today's date in YYYY-MM-DD format.

  3. The correct way to import and use the datetime python library

    Mar 18, 2012 · 2 The datetime module contains a number of classes, including the class datetime.datetime. If you don't care about the other functions in the module, you can write: from …

  4. Difference between Python datetime vs time modules

    Aug 15, 2017 · The time module is principally for working with Unix time stamps; expressed as a floating point number taken to be seconds since the Unix epoch. the datetime module can support many of …

  5. How do I find the time difference between two datetime objects in …

    datetime.seconds and datetime.microseconds are capped to [0,86400) and [0,10^6) respectively. They should be used carefully if timedelta is bigger than the max returned value.

  6. How can I specify date and time in Python? - Stack Overflow

    Apr 10, 2022 · What is the object used in Python to specify date (and time) in Python? For instance, to create an object that holds a given date and time, (let's say '05/10/09 18:00').

  7. Datetime current year and month in Python - Stack Overflow

    There's also timedelta and tzinfo in there. One could just import datetime to get the whole package with all the submodules, but then method calls would look like datetime.datetime.now() or …

  8. datetime - How do I get the current time in milliseconds in Python ...

    Jun 17, 2019 · 201 For Python 3.7+, time.time_ns() gives the time passed in nanoseconds since the epoch. This gives time in milliseconds as an integer:

  9. Python datetime module and getting current time

    Nov 15, 2020 · The datetime class is a little confusing to import because it's in a module that's also called datetime. When you do from datetime import datetime you're importing the class datetime into …

  10. datetime - Python Timezone conversion - Stack Overflow

    Jun 12, 2012 · Time conversion To convert a time in one timezone to another timezone in Python, you could use datetime.astimezone (): so, below code is to convert the local time to other time zone. …