All Projects → kevinkhill → Php Duration

kevinkhill / Php Duration

Licence: mit
Convert durations of time between colon-formatted, human-readable, and seconds

Labels

Projects that are alternatives of or similar to Php Duration

Parallel-Tacotron2
PyTorch Implementation of Google's Parallel Tacotron 2: A Non-Autoregressive Neural TTS Model with Differentiable Duration Modeling
Stars: ✭ 149 (+5.67%)
Mutual labels:  duration
Kotlinpleaseanimate
Kotlin, please, can you animate my views ?
Stars: ✭ 541 (+283.69%)
Mutual labels:  duration
Moment Timer
Timer plugin for Moment.js that allows creation of setInterval and setTimeout-like timers.
Stars: ✭ 98 (-30.5%)
Mutual labels:  duration
Toast
To use it in PCL or .NetStandard projects write this line of code : CrossToastPopUp.Current.ShowToastMessage("Message");
Stars: ✭ 51 (-63.83%)
Mutual labels:  duration
Time.dart
⏰ Type-safe DateTime and Duration calculations, powered by extensions.
Stars: ✭ 363 (+157.45%)
Mutual labels:  duration
Alignmentduration
Lyrics-to-audio-alignement system. Based on Machine Learning Algorithms: Hidden Markov Models with Viterbi forced alignment. The alignment is explicitly aware of durations of musical notes. The phonetic model are classified with MLP Deep Neural Network.
Stars: ✭ 36 (-74.47%)
Mutual labels:  duration
WaveGrad2
PyTorch Implementation of Google Brain's WaveGrad 2: Iterative Refinement for Text-to-Speech Synthesis
Stars: ✭ 55 (-60.99%)
Mutual labels:  duration
Favesound Redux
🎶 A SoundCloud Client in React + Redux running in production. Live Demo and Source Code to explore React + Redux as a beginner.
Stars: ✭ 1,586 (+1024.82%)
Mutual labels:  duration
Durafmt
🕗 Better time duration formatting in Go!
Stars: ✭ 362 (+156.74%)
Mutual labels:  duration
Humanizeduration.js
361000 becomes "6 minutes, 1 second"
Stars: ✭ 1,234 (+775.18%)
Mutual labels:  duration
Licensy
Discord bot that manages expiration of roles with subscriptions!
Stars: ✭ 47 (-66.67%)
Mutual labels:  duration
Time4j
Advanced date, time and interval library for Java with sun/moon-astronomy and calendars like Chinese, Coptic, Ethiopian, French Republican, Hebrew, Hijri, Historic Christian, Indian National, Japanese, Julian, Korean, Minguo, Persian, Thai, Vietnamese
Stars: ✭ 328 (+132.62%)
Mutual labels:  duration
Aion
A friendly Rust utility crate for duration and datetime
Stars: ✭ 37 (-73.76%)
Mutual labels:  duration
Flutter-Anim
Fluent Flutter Animation library. Describe Sequences & Parallel animation's workflow, setup startDelay, duration and curve, then run !
Stars: ✭ 35 (-75.18%)
Mutual labels:  duration
Livesmashbar
An elegant looking and easy to use informative library with LiveData integration for Android.
Stars: ✭ 107 (-24.11%)
Mutual labels:  duration
youtube-playlist-duration
A Google Chrome extension for calculating the duration of YouTube playlists.
Stars: ✭ 24 (-82.98%)
Mutual labels:  duration
Time
Windows tool for measuring command/program execution speed
Stars: ✭ 21 (-85.11%)
Mutual labels:  duration
As Duration
Extraction of ActiveSupport::Duration from Rails
Stars: ✭ 126 (-10.64%)
Mutual labels:  duration
Ruby Duration
Immutable type that represents some amount of time with accuracy in seconds.
Stars: ✭ 122 (-13.48%)
Mutual labels:  duration
Csnackbar
This is a wrapper for android Snackbar. Which giving support to change Snackbar color, duration, message or even it's content view with a custom view.
Stars: ✭ 76 (-46.1%)
Mutual labels:  duration

PHP-Duration

Convert durations between colon formatted time, human-readable time and seconds

Total Downloads License Minimum PHP Version PayPal

Current Release Build Status Coverage Status

This package was created with a very specific goal in mind, to enable an easy way for users to input how long something took, as a duration of time.

The library can accept either in colon separated format, like 2:43 for 2 minutes and 43 seconds OR written as human readable or abbreviated time, such as 6m21s for 6 minutes and 21 seconds.

Both can be converted into seconds and minutes with precision for easy storage into a database.

Seconds, colon separated, abbreviated, all three can be parsed and interchanged.

  • supports hours, minutes, and seconds (with microseconds)
  • humanized input supports any form of the words "hour", "minute", "seconds"
    • Example, you could input 1h4m2s or 4 Hr. 32 Min.

Install

composer require khill/php-duration:~1.0

Usage

use Khill\Duration\Duration;


$duration = new Duration('7:31');

echo $duration->humanize();  // 7m 31s
echo $duration->formatted(); // 7:31
echo $duration->toSeconds(); // 451
echo $duration->toMinutes(); // 7.5166
echo $duration->toMinutes(null, 0); // 8
echo $duration->toMinutes(null, 2); // 7.52
$duration = new Duration('1h 2m 5s');

echo $duration->humanize();  // 1h 2m 5s
echo $duration->formatted(); // 1:02:05
echo $duration->toSeconds(); // 3725
echo $duration->toMinutes(); // 62.0833
echo $duration->toMinutes(null, 0); // 62
// Configured for 6 hours per day
$duration = new Duration('1.5d 1.5h 2m 5s', 6);

echo $duration->humanize();  // 1d 4h 32m 5s
echo $duration->formatted(); // 10:32:05
echo $duration->toSeconds(); // 37925
echo $duration->toMinutes(); // 632.083333333
echo $duration->toMinutes(null, 0); // 632
$duration = new Duration('4293');

echo $duration->humanize();  // 1h 11m 33s
echo $duration->formatted(); // 1:11:33
echo $duration->toSeconds(); // 4293
echo $duration->toMinutes(); // 71.55
echo $duration->toMinutes(null, 0); // 72

Note

You do not have to create a new object for each conversion, you can also pass any of the three forms into any of the methods to get the immediate output.

$duration = new Duration;

echo $duration->humanize('1h 2m 5s');  // 1h 2m 5s
echo $duration->formatted('1h 2m 5s'); // 1:02:05
echo $duration->toSeconds('1h 2m 5s'); // 3725
echo $duration->toMinutes('1h 2m 5s'); // 62.0833
echo $duration->toMinutes('1h 2m 5s', true); // 62
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].