logo
down
shadow

convert a DURATION HH:MM:SS to seconds in bash


convert a DURATION HH:MM:SS to seconds in bash

Content Index :

convert a DURATION HH:MM:SS to seconds in bash
Tag : bash , By : geo
Date : November 24 2020, 05:44 AM


Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to convert YouTube API duration (ISO 8601 duration in the format PT#M#S) to seconds


Tag : javascript , By : Dmitry
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


Tag : r , By : Shawazi
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());
Related Posts Related QUESTIONS :
  • How to stop $ / being stripped of a string being inserted into a file with sed?
  • Compare lines of a 'specific' column and join the other columns if the lines of the 'specific' colum match
  • How do I recursively append a unique identifier to a series of identical strings in bash?
  • How to sudo su; then run command
  • How to resolve a syntax error of "unexpected token 'then'"?
  • Bash: Terminate on Timeout/File Overflow while Executing Command
  • Recursive FTP directory listing in shell/bash with a single session (using cURL or ftp)
  • Bash: Conditional Statement Without IF via Grouping Commands and Boolean Operators
  • How to dynamically define a path using a file prefix within a directory?
  • Track pg_dump process id and trigger an error while it fails
  • Multiple commands: do not continue on error
  • How to alias a command if the command contains a certain word at the beginning
  • How to use the exit code of netcat command in a if condition?
  • How can I take multiple arguments in bash using getopts?
  • Name for ${...} constructs (for strings and arrays) in bash?
  • How to determine if an EXIT trap is defined for a BASH subshell?
  • How can you tokenize a bash string into an array when the string includes a * character?
  • Use OPTARG as variable in shell script, no matter the order of arguments
  • Why does my loop occasionally not read the entire line?
  • Is there any shorter syntax for changing several directory levels back up with bash cd?
  • Correctly formatting a PYTHONPATH in my .bash_profile
  • Bash Script : Check if number starts with
  • im getting a syntax error when i run my shell script, the error is in my for each loop and says unespected token `;;'
  • Write a shell script that will return the list of files skipped by your repository git
  • Create a shell script that returns the last 5 hash of my commits of my git deposit
  • How to copy Associative Array without for loop
  • Extract specific string from line with standard grep,egrep or awk
  • Copy files that have at least the mention of one certain word
  • How it exactly works?
  • How to insert a specific character at a specific line of a file using sed or awk?
  • How to create bash script that combines specified list of items at random?
  • How to get the return code from the bash command
  • Running a bash find with file cp parameter error python script
  • How to pass a file as an argument to a bash script function?
  • How can I pass a complex file glob to a subshell?
  • Standard-in parse errors with bc command
  • Using AWK to merge unique rows based on column one
  • Bash Login Script Stalls
  • BASH replace a single letter only when it's alone not in a word
  • Compare 4 files line by line to see if they match or don't match
  • Add character to file name if duplicate when moving with bash
  • Use grep only on specific columns in many files?
  • xor conditional in bash
  • Fails to create azure container right after storage account was created
  • bash: arithmetic expressions inside of variables
  • jq command throws error "cannot iterate over string" when
  • In Bash, should I use declare instead of local and export?
  • Grouping command substitution variables into a subshell to run in background
  • How to display number of items in a folder - Bash
  • How to create a new procedure from bash script
  • Sed command to uppercase text between two specific strings
  • Escape double quotes in a Jenkins pipeline file's shell command
  • pgrep -f cuts commands after 4095 characters
  • I want my script to echo "$1" into a file literally
  • Shell script: unexpected token ┬┤if"
  • scp error when defining a "PATH" variable in a bash script
  • Nested loop for reading two files with bash
  • Find folders with a specific name and run bash commands on each location
  • Replication and expansion of program flags in BASH script
  • Error on certain line: Syntax error: "(" unexpected
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com