<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) &gt; [deltaTime](./brick-next-pipes.deltatime.md)

## deltaTime() function

将一个时间段转换为人类可读的文本。

 Datetime

**Signature:**

```typescript
export declare function deltaTime(time: number | string | Period, withSuffix?: boolean, format?: string): string;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  time | number \| string \| [Period](./brick-next-pipes.period.md) | 指定时间（字符串或 UNIX 时间戳）或时间段。 |
|  withSuffix | boolean | 是否添加后缀（默认为 <code>true</code>）。 |
|  format | string | 输入的时间格式（使用时间戳时可忽略，默认为 <code>&quot;YYYY-MM-DD HH:mm:ss&quot;</code>）。 |

**Returns:**

string

人类可读的时间段显示。

## Remarks

给定一个时间段（`startTime` 和 `endTime`<!-- -->），将它转换为人类可读的文本。

当输入时间为单个值时，则计算它与当前时间的间隔时间段。

## Example


```ts
// Assuming now is "2019-05-10 17:51:00".

deltaTime("2019-05-10 17:21:00")
// Returns "30 minutes ago"

deltaTime("2019-05-10 18:51:00")
// Returns "in an hour"

deltaTime({ startTime: "2019-05-10", endTime: "2019-06-10" }, false)
// Returns "a month"

deltaTime({ startTime: "2019-05-10 17:48:00" }, false)
// Returns "3 minutes"
```


