About 4,520,000 results
Open links in new tab
  1. datetime - 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. python - How to determine if a variable is a datetime object? - Stack ...

    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 …

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

  4. Subtracting datetime objects with Python - Stack Overflow

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

  5. Convert DataFrame column type from string to datetime

    Jun 16, 2013 · How can I convert a DataFrame column of strings (in dd/mm/yyyy format) to datetime dtype?

  6. How to convert string to datetime in python - Stack Overflow

    Mar 7, 2011 · I have a date string in following format 2011-03-07 how to convert this to datetime in python?

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

  8. python - Convert Pandas Column to DateTime - Stack Overflow

    50 Use the pandas to_datetime function to parse the column as DateTime. Also, by using infer_datetime_format=True, it will automatically detect the format and convert the mentioned column …

  9. Convert date to datetime in Python - Stack Overflow

    Dec 21, 2009 · Is there a built-in method for converting a date to a datetime in Python, for example getting the datetime for the midnight of the given date? The opposite conversion is easy: datetime …

  10. How can I overcome "datetime.datetime not JSON serializable"?

    If you are using Python 3.6 or below, and you only care about the time value (not the timezone), then you can use datetime.timestamp() and datetime.fromtimestamp() instead;