Questions tagged [time]

Measuring the time it takes to perform an operation. Also, questions related to obtaining the current time, calculating on times, formatting and parsing times, etc.

Measuring the time it takes to perform an operation. Also, questions related to obtaining the current time, calculating on times, formatting and parsing times, etc. See also and .

For analysis in , consider looking at the Time Series Task View.

29686 questions
450
votes
29 answers

How to change time in DateTime?

How can I change only the time in my DateTime variable "s"? DateTime s = some datetime;
Santhosh
  • 19,616
  • 22
  • 63
  • 74
425
votes
16 answers

Command to get time in milliseconds

Is there a shell command in Linux to get the time in milliseconds?
MOHAMED
  • 41,599
  • 58
  • 163
  • 268
418
votes
7 answers

time.sleep -- sleeps thread or process?

In Python for *nix, does time.sleep() block the thread or the process?
Jeremy Dunck
  • 5,724
  • 6
  • 25
  • 30
412
votes
16 answers

How to get current time in milliseconds in PHP?

time() is in seconds - is there one in milliseconds?
COMer
  • 5,091
  • 4
  • 22
  • 20
408
votes
47 answers

JavaScript seconds to time string with format hh:mm:ss

I want to convert a duration of time, i.e., number of seconds to colon-separated time string (hh:mm:ss) I found some useful answers here but they all talk about converting to x hours and x minutes format. So is there a tiny snippet that does this in…
medk
  • 9,233
  • 18
  • 57
  • 79
408
votes
2 answers

Get first and last date of current month with JavaScript or jQuery

As title says, I'm stuck on finding a way to get the first and last date of the current month with JavaScript or jQuery, and format it as: For example, for November it should be : var firstdate = '11/01/2012'; var lastdate = '11/30/2012';
Moozy
  • 4,735
  • 3
  • 18
  • 18
398
votes
26 answers

Easily measure elapsed time

I am trying to use time() to measure various points of my program. What I don't understand is why the values in the before and after are the same? I understand this is not the best way to profile my program, I just want to see how long something…
hap497
  • 154,439
  • 43
  • 83
  • 99
393
votes
37 answers

Convert seconds to HH-MM-SS with JavaScript?

How can I convert seconds to an HH-MM-SS string using JavaScript?
Hannoun Yassir
  • 20,583
  • 23
  • 77
  • 112
392
votes
30 answers

Convert seconds to Hour:Minute:Second

I need to convert seconds to "Hour:Minute:Second". For example: "685" converted to "00:11:25" How can I achieve this?
EzzDev
  • 9,900
  • 12
  • 35
  • 35
379
votes
10 answers

Measuring elapsed time with the Time module

With the Time module in python is it possible to measure elapsed time? If so, how do I do that? I need to do this so that if the cursor has been in a widget for a certain duration an event happens.
rectangletangle
  • 50,393
  • 94
  • 205
  • 275
376
votes
26 answers

How to format date and time in Android?

How to format correctly according to the device configuration date and time when having a year, month, day, hour and minute?
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
361
votes
15 answers

How do I measure time elapsed in Java?

I want to have something like this: public class Stream { public startTime; public endTime; public getDuration() { return startTime - endTime; } } Also it is important that for example if the startTime it's 23:00 and…
Omu
  • 69,856
  • 92
  • 277
  • 407
349
votes
15 answers

Measuring function execution time in R

Is there a standardized way in R of measuring execution time of function? Obviously I can take system.time before and after execution and then take the difference of those, but I would like to know if there is some standardized way or function…
dns
  • 3,491
  • 2
  • 15
  • 3
344
votes
5 answers

In Python, how do you convert seconds since epoch to a `datetime` object?

The time module can be initialized using seconds since epoch: >>> import time >>> t1=time.gmtime(1284286794) >>> t1 time.struct_time(tm_year=2010, tm_mon=9, tm_mday=12, tm_hour=10, tm_min=19, tm_sec=54, tm_wday=6, tm_yday=255,…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
337
votes
21 answers

How to get time difference in minutes in PHP

How to calculate minute difference between two date-times in PHP?
Tom Smykowski
  • 25,487
  • 54
  • 159
  • 236