About 6,080,000 results
Open links in new tab
  1. python - How to determine if a variable is a datetime object?

    While this works for datetime, it doesn't work for date, because datetime is a subclass of date. For example if you try to test isinstance(my_datetime, datetime.date) it will return true, which you …

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

    Since Python 3.9, you can use the built-in zoneinfo library to get timezones. Then once you get today's date as a datetime.datetime object, it's straightforward to convert to a string in the …

  3. 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 …

  4. 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.

  5. Subtracting datetime objects with Python - Stack Overflow

    10 When substracting two datetime objects you will get a new datetime.timedelta object.

  6. python - How to convert local time string to UTC ... - Stack Overflow

    You can convert a datetime string to utc time in python by generating a datetime object and then you can use astimezone (pytz.utc) to get datetime in utc. For eg.

  7. python - How do I sort a list of datetime or date objects ... - Stack ...

    Jan 23, 2013 · How do I sort a list of date and/or datetime objects? The accepted answer here isn't working for me: from datetime import datetime,date,timedelta a= [date.today (), date.today …

  8. datetime - How to get UTC time in Python? - Stack Overflow

    Apr 11, 2013 · from datetime import datetime, timezone datetime.now(timezone.utc) datetime.now(timezone.utc).timestamp() * 1000 # POSIX timestamp in milliseconds For your …

  9. python - Converting Unix timestamp string to readable date

    I have a string representing a Unix timestamp (i.e. "1284101485") in Python, and I'd like to convert it to a readable date. When I use time.strftime, I get TypeError: import time print time.

  10. python - How to subtract a day from a date? - Stack Overflow

    Jan 13, 2009 · I have a Python datetime.datetime object. What is the best way to subtract one day?