Home Explore Blog CI



nushell

commands/docs/format_duration.md
0c793bb4d2b21d7c323a5992fb7e14e7188278e22fec43e10000000300000592
---
title: format duration
categories: |
  strings
version: 0.104.0
strings: |
  Outputs duration with a specified unit of time.
usage: |
  Outputs duration with a specified unit of time.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `format duration` for [strings](/commands/categories/strings.md)

<div class='command-title'>Outputs duration with a specified unit of time.</div>

## Signature

```> format duration {flags} (format value) ...rest```

## Parameters

 -  `format value`: The unit in which to display the duration.
 -  `...rest`: For a data structure input, format duration at the given cell paths.


## Input/output types:

| input          | output       |
| -------------- | ------------ |
| duration       | string       |
| list\<duration\> | list\<string\> |
| table          | table        |
## Examples

Convert µs duration to the requested second duration as a string
```nu
> 1000000µs | format duration sec
1 sec
```

Convert durations to µs duration as strings
```nu
> [1sec 2sec] | format duration µs
╭───┬────────────╮
│ 0 │ 1000000 µs │
│ 1 │ 2000000 µs │
╰───┴────────────╯

```

Convert duration to µs as a string if unit asked for was us
```nu
> 1sec | format duration us
1000000 µs
```

Chunks
914f33e5 (1st chunk of `commands/docs/format_duration.md`)
Title: format duration
Summary
The `format duration` command in Nushell outputs a duration value as a string, formatted according to a specified unit of time. It can accept a single duration, a list of durations, or a table with duration values in specified columns, converting them to the requested unit (e.g., seconds, microseconds) and returning them as strings.