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

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

  5. How do I get a string format of the current date time, in python?

    You can use the datetime module for working with dates and times in Python. The strftime method allows you to produce string representation of dates and times with a format you specify.

  6. datetime - Creating a range of dates in Python - Stack Overflow

    Feb 2, 2012 · I want to create a list of dates, starting with today, and going back an arbitrary number of days, say, in my example 100 days. Is there a better way to do it than this? import datetime a = datet...

  7. python - How do you convert a datetime/timestamp from one …

    Aug 13, 2015 · 11 How do you convert datetime/timestamp from one timezone to another timezone? There are two steps: Create an aware datetime objects from the system time and timezone e.g., to …

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

  9. Subtracting datetime objects with Python - Stack Overflow

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

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

    Apr 11, 2013 · For Python 3, use datetime.now(timezone.utc) to get a timezone-aware datetime, and use .timestamp() to convert it to a timestamp. from datetime import datetime, timezone …