I would like to measure elapsed time in days with the Python time module. My attempt is:  import time, datetime  def elapsed_time(start)     return datetime.datetime.fromtimestamp(time.time()-start).strftime('%Y-%m-%d-%H-%M-%S')  start = time.time() print(elapsed_time(start)) # 1970-01-01-00-00-06   I would like the string to start from year 0, month 0, and day 0. How do I do that?
26085
I'm having trouble formatting a datetime.timedelta object.  Here's what I'm trying to do:    I have a list of objects and one of the members of the class of the object is a timedelta object that shows the duration of an event.  I would like to display that duration in the format of hours:minutes.  I have tried a variety of methods for doing this and I'm having difficulty.  My current approach is to add methods to the class for my objects that return hours and minutes.  I can get the hours by dividing the timedelta.seconds by 3600 and rounding it. I'm having trouble with getting the remainder seconds and converting that to minutes.  By the way, I'm using Google AppEngine with Django Templates for presentation.
57629
How do I get the time since the epoch, in milliseconds, in the OSX terminal?  The Linux/Ubuntu equivalent is date +%s.%N:  Linux $ date +%s.%N 1403377762.035521859   Which does not work in my OSX terminal:  OSX $ date +%s.%N 1403377800.N
51460
I've used the  function in Perl to get the current date and time but need to parse in existing dates. I have a GMT date in the following format: "20090103 12:00" I'd like to parse it into a date object I can work with and then convert the GMT time/date into my current time zone which is currently Eastern Standard Time. So I'd like to convert "20090103 12:00" to "20090103 7:00" any info on how to do this would be greatly appreciated.
7708
How to add days to current Date using JavaScript. Does JavaScript have a built in function like .Net's AddDay?
101598
I am trying to implement the python logging handler TimedRotatingFileHandler. When it rolls over to midnight it appends the current day in the form YYYY-MM-DD. LOGGING_MSG_FORMAT  = '%(name)-14s &gt; [%(levelname)s] [%(asctime)s] : %(message)s' LOGGING_DATE_FORMAT = '%Y-%m-%d %H:%M:%S'  logging.basicConfig(             level=logging.DEBUG,             format=LOGGING_MSG_FORMAT,             datefmt=LOGGING_DATE_FORMAT             ) root_logger = logging.getLogger('') logger = logging.handlers.TimedRotatingFileHandler(&quot;C:\\logs\\Rotate_Test&quot;,'midnight',1) root_logger.addHandler(logger) while True:     daemon_logger = logging.getLogger('TEST')     daemon_logger.info(&quot;SDFKLDSKLFFJKLSDD&quot;)     time.sleep(60)  The first log file created is named Rotate_Test, then once it rolls over to the next day it changes the file name to Rotate_Test.YYYY-MM-DD where YYYY-MM-DD is the current day. How can I change how it alters the filename?
600
How do I get the number of days between two dates in JavaScript? For example, given two dates in input boxes:  &lt;input id="first" value="1/1/2000"/&gt; &lt;input id="second" value="1/1/2001"/&gt;  &lt;script&gt;   alert(datediff("day", first, second)); // what goes here? &lt;/script&gt;
72106
Total newbie question here; I apologize in advance.  Suppose I have a daemon written in C that wakes itself up every five minutes or so, does some processing if there's anything in its input queue, and then goes back to sleep. Now suppose there is some processing that it only has to do after a certain (configurable) time--say, 2 pm (and before midnight).  In C, what is the quickest, best way to get the current time's hour into an int variable, so that it can easily be checked against--to determine if, in fact, it is after 2pm on today?
12890
I am using the datetime Python module.  I am looking to calculate the date 6 months from the current date. Could someone give me a little help doing this?  The reason I want to generate a date 6 months from the current date is to produce a review date.  If the user enters data into the system it will have a review date of 6 months from the date they entered the data.
32655
I have a Python  object. What is the best way to subtract one day?
68699
Following on from my previous question, , I have now come across a problem regarding the timezone, and it turns out that it's not always going to be "+0200". So when strptime tries to parse it as such, it throws up an exception.  I thought about just chopping off the +0200 with [:-6] or whatever, but is there a real way to do this with strptime?  I am using Python 2.5.2 if it matters.  &gt;&gt;&gt; from datetime import datetime &gt;&gt;&gt; fmt = "%a, %d %b %Y %H:%M:%S +0200" &gt;&gt;&gt; datetime.strptime("Tue, 22 Jul 2008 08:17:41 +0200", fmt) datetime.datetime(2008, 7, 22, 8, 17, 41) &gt;&gt;&gt; datetime.strptime("Tue, 22 Jul 2008 08:17:41 +0300", fmt) Traceback (most recent call last):   File "&lt;stdin&gt;", line 1, in &lt;module&gt;   File "/usr/lib/python2.5/_strptime.py", line 330, in strptime     (data_string, format)) ValueError: time data did not match format:  data=Tue, 22 Jul 2008 08:17:41 +0300  fmt=%a, %d %b %Y %H:%M:%S +0200
81732
How do you get the current time (not date AND time)?  Example: 5:42:12 PM
2178
Why doesn't the following work (Python 2.5.2)?  &gt;&gt;&gt; import datetime &gt;&gt;&gt; class D(datetime.date):         def __init__(self, year):             datetime.date.__init__(self, year, 1, 1) &gt;&gt;&gt; D(2008) Traceback (most recent call last):   File "&lt;stdin&gt;", line 1, in &lt;module&gt; TypeError: function takes exactly 3 arguments (1 given)   I wanted to create a class that was just like datetime.date, but with a different __init__ function.  Apparently my function never gets called.  Instead the original datetime.date.__init__ is called and fails because that expects 3 arguments and I am passing in one.  What's going on here?  And is this a clue?  &gt;&gt;&gt; datetime.date.__init__ &lt;slot wrapper '__init__' of 'object' objects&gt;   Thanks!
99127
Is there a function or method to give the last day of a month? For example if the date is 27 feb 2013, the last date should be 28 feb 2013 , it become 29 if its a leap year. if the date was 2 jan then it should return 31 Jan.  If there is no function then any ideas on how we can get this?  Thanks
17330
I need to convert an arbitrary amount of milliseconds into Days, Hours, Minutes Second.  For example: 10 Days, 5 hours, 13 minutes, 1 second.
94663
How can i convert a string like this Wed Aug 07 04:30:00 GMT 2013 to a dateTime value?
67323
Why is a signed integer used to represent timestamps? There is a clearly defined start at 1970 that's represented as 0, so why would we need numbers before that? Are negative timestamps used anywhere?
63556
I found the question about converting epoch time to normal time, but I'm having two problems:   When I run DateTime.newInstance(1391529600 * 1000) I am getting the wrong answer I want to convert normal time to epoch time   1: I have been typing the following into Execute Anonymous:  system.debug(DateTime.newInstance(1391529600 * 1000));   By my calculations (and some websites I found) that should give me 4 Feb, 2014, 16:00:00 GMT.  Apex gives me      1969-12-31 12:56:36   Clearly, this is incorrect (and it's even before 1/1/1970). Can anyone replicate my situation?  2: I also want to change the current datetime (GMT) to epoch time, returning the number of seconds or milliseconds since 1/1/1970. I could break things into parts, but that seems an awful lot of script statements to do something that should be fairly easy, I'd hope.  Thanks for the help!