Convert seconds to human readable string(s)
Anmerkung des Herausgebers: This file was selected as MATLAB Central Pick of the Week
This function converts a (usually large) amount of seconds to human-readable string. For example,
>> str = seconds2human(1463456.3)
str =
'About 2 weeks and 2 days.'
You may also call the function with a second input argument; either 'short' (the default) or 'full'. This determines the level of detail returned in the string:
>> str = seconds2human(1463456.3, 'full')
str =
'2 weeks, 2 days, 22 hours, 30 minutes, 56 seconds.'
The 'short' format returns only the two largest units of time.
Furthermore, [secs] may be an NxM-matrix, in which case the output is an NxM cell array of the corresponding strings.
Zitieren als
Rody Oldenhuis (2025). Convert seconds to human readable string(s) (https://github.com/rodyo/FEX-seconds2human/releases/tag/v1.6), GitHub. Abgerufen.
Kompatibilität der MATLAB-Version
Plattform-Kompatibilität
Windows macOS LinuxKategorien
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Live Editor erkunden
Erstellen Sie Skripte mit Code, Ausgabe und formatiertem Text in einem einzigen ausführbaren Dokument.
Versionen, die den GitHub-Standardzweig verwenden, können nicht heruntergeladen werden
Version | Veröffentlicht | Versionshinweise | |
---|---|---|---|
1.6 | See release notes for this release on GitHub: https://github.com/rodyo/FEX-seconds2human/releases/tag/v1.6 |
||
1.5.0.0 | Description update
|
|
|
1.4.0.0 | - Added 'decennium' as a time unit
|
||
1.3.0.0 | Updated contact info |
||
1.2.0.0 | - reduced the default verbosity, as suggested by Jos. The verbosity can now be changed with a second argument. - Included (sec < 1) case, as suggested by Jesse. |
||
1.1.0.0 | updated code thanks to Jos' comments. |
||
1.0.0.0 |