How to convert YouTube API duration (ISO 8601 duration in the format PT#M#S) to seconds
Date : March 29 2020, 07:55 AM
I wish this help you Here's the basic code to get total number of seconds and other parts. I feel uneasy doing this, as the rule says that any time you want to date logic you shouldn't :) But anyways, here it goes - Google made it not easy, providing total seconds in the getduration player API, and providing totally different format in the gdata api. var reptms = /^PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?$/;
var hours = 0, minutes = 0, seconds = 0, totalseconds;
if (reptms.test(input)) {
var matches = reptms.exec(input);
if (matches[1]) hours = Number(matches[1]);
if (matches[2]) minutes = Number(matches[2]);
if (matches[3]) seconds = Number(matches[3]);
totalseconds = hours * 3600 + minutes * 60 + seconds;
}
|
Convert seconds to Duration XPATH
Tag : xml , By : Robert Daniel Pickar
Date : March 29 2020, 07:55 AM
help you fix your problem If you don't mind seeing zeros in the output, you can use integer division and modulo operations to separate the value into hours, minutes, seconds, and days: The number of seconds is the input value modulo 60. (Discard everything but the "second hand") concat(floor($NUMSEC div 86400),' Days ',floor($NUMSEC div 3600) mod 24,' Hours ',
floor($NUMSEC div 60) mod 60,' Minutes ',$NUMSEC mod 60,' Seconds'
|
Convert a duration %H:%M:%S to seconds
Date : March 29 2020, 07:55 AM
will be helpful for those in need After we convert it to POSIXlt, extract the hour, min and sec and do the arithmetic v1 <- strptime(durations, format='%H:%M:%S')
v1$hour * 3600 + v1$min * 60 + v1$sec
#[1] 3661
c(unlist(unclass(v1)[c("hour", "min", "sec")]) %*% c(3600, 60, 1))
|
Convert Duration to Seconds in SQL
Tag : sql , By : codelurker
Date : March 29 2020, 07:55 AM
hop of those help? One method is to convert the string to a time type and then use time arithmetic: select datediff(second, 0, cast('00:' + right('0' + duration, 5) as time))
select cast(left(duration, charindex(':', t) - 1) as int)*60 + cast(right(duration, 2) as int)
|
How to convert Duration to seconds?
Tag : java , By : terrestrial
Date : March 29 2020, 07:55 AM
it helps some times , What you are looking for is the following: System.out.println(duration.getSeconds()%60);
System.out.println(duration.getSeconds() - duration.toMinutes()*60);
System.out.println(duration.toSecondsPart());
|