Date formats and its difference in python
Question: I have two dates in below formats:

    
    
    d1 = "Fri, 16 Oct 2015 18:06:37 +0530"
    d2 = "Thu, 1 Oct 2015 17:12:00 +0530"
    

I need to find the number of days between these two dates.


Answer: I like the dateutil library:

    
    
    from dateutil import parser
    
    d1 = parser.parse("Fri, 16 Oct 2015 18:06:37 +0530")
    d2 = parser.parse("Thu, 1 Oct 2015 17:12:00 +0530")
    
    print d1-d2
    print (d1-d2).days
    

output:

    
    
    15 days, 0:54:37
    15
    

