Questions tagged [duration]

The measure of continuance of any object or event within time.

The measure of continuance of any object or event within time.

See also the and tags.

1431 questions
269
votes
31 answers

How to use format() on a moment.js duration?

Is there any way I can use the moment.js format method on duration objects? I can't find it anywhere in the docs and it doesn't seen to be an attribute on duration objects. I'd like to be able to do something like: var diff = moment(end).unix() -…
mvanveen
  • 9,754
  • 8
  • 33
  • 42
225
votes
22 answers

How to format a duration in java? (e.g format H:MM:SS)

I'd like to format a duration in seconds using a pattern like H:MM:SS. The current utilities in java are designed to format a time but not a duration.
kofte
144
votes
2 answers

How does '20 seconds' work in Scala?

How does the following compile: import scala.concurrent.duration._ val time = 20 seconds What is actually going on here?
ripper234
  • 222,824
  • 274
  • 634
  • 905
111
votes
7 answers

What is the duration of a Toast LENGTH_LONG and LENGTH_SHORT

I need the exact duration of LENGTH_LONG and LENGTH_SHORT in milliseconds (ms). Also I need to know if the duration of Toast message with LENGTH_LONG will have the same duration in any phone and with any API version. Does someone know where is the…
Lukap
  • 31,523
  • 64
  • 157
  • 244
95
votes
3 answers

What does 'PT' prefix stand for in Duration?

I am trying to use the Duration class instead of long. It has superior literal syntax. I like its flexibility, though it looks weird. "PT10S" means 10 seconds, what is the problem to accept "10 seconds"?! Okay never mind. I am just curious why PT…
Daniil Iaitskov
  • 5,525
  • 8
  • 39
  • 49
68
votes
6 answers

How to format a duration as HH:mm?

In the new Google sheets there's a way of formatting a number as a duration. Format -> Number -> Duration. 1 is formatted as 24:00:00 1.2 is formatted as 28:48:00 1.5 is formatted as 36:00:00 0.03125 is formatted as 0:45:00. I don't need the…
Christiaan Westerbeek
  • 10,619
  • 13
  • 64
  • 89
61
votes
9 answers

How to get the duration of an audio file in iOS?

NSDictionary* fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filename error:nil] From the file attribute keys, you can get the date, size, etc. But how do you get…
Namratha
  • 16,630
  • 27
  • 90
  • 125
60
votes
4 answers

Converting Java to Scala durations

Is there an elegant way to convert java.time.Duration to scala.concurrent.duration.FiniteDuration? I am trying to do the following simple use of Config in Scala: val d = ConfigFactory.load().getDuration("application.someTimeout") However I don't see…
Jacob Eckel
  • 1,633
  • 1
  • 13
  • 22
56
votes
4 answers

How to get video duration, dimension and size in PHP?

I want to know how to get the duration, dimension and size of uploaded video file in PHP. The file can be in any video format.
Chandan
  • 563
  • 1
  • 5
  • 4
51
votes
8 answers

Measuring elapsed time in python

Is there a simple way / module to correctly measure the elapsed time in python? I know that I can simply call time.time() twice and take the difference, but that will yield wrong results if the system time is changed. Granted, that doesn't happen…
Medo42
  • 3,821
  • 1
  • 21
  • 37
50
votes
6 answers

current/duration time of html5 video?

I need a way of getting the total time length of the video and the current time with jquery and displaying it in a couple of
tags.
0:00
0:00
I've been searching all day and I know how to get…
Cody
  • 1,281
  • 2
  • 10
  • 12
46
votes
9 answers

PHP: add seconds to a date

I have $adate; which contains: Tue Jan 4 07:59:59 2011 I want to add to this date the following: $duration=674165; // in seconds Once the seconds are added I need the result back into date format. I don't know what I'm doing, but I am getting odd…
ADM
  • 1,590
  • 11
  • 36
  • 54
44
votes
5 answers

Formatting a Duration in Java 8 / jsr310

I am transitioning a project from Joda-Time to java8's native time libraries, and I have run into a snag. I have been unable to find a formatter for Duration. I would like to have a custom String format of, for instance, HHH+MM, where a Duration of…
Chad Lowe
  • 721
  • 1
  • 6
  • 12
44
votes
8 answers

How can I get the html5 audio's duration time

I have a html5
hh54188
  • 14,887
  • 32
  • 113
  • 184
41
votes
5 answers

Finding the length of an mp3 file

So i have the code: import glob,os import random path = 'C:\\Music\\' aw=[] for infile in glob.glob( os.path.join(path,'*.mp3') ): libr = infile.split('Downloaded',1) aw.append(infile) aww = -1 while 1: aww += 1 print…
P'sao
  • 2,946
  • 11
  • 39
  • 48
1
2 3
95 96