> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xray.cool/llms.txt
> Use this file to discover all available pages before exploring further.

# timeConvert

> `timeConvert`主要是用来对时间的格式进行转换的函数，可以将指定时间戳转换成自定义格式的字符串。本质上是使用 golang 的 time 包提供的 Format 方法

## 函数原型

`func timeConvert(t1 int, s1 string) string`

### 参数介绍

| 参数名称 | 参数介绍     |
| ---- | -------- |
| t1   | 需要转换的时间戳 |
| s1   | 要转换的格式   |

* 以下是 golang 中 time 包对于时间的详细定义

  | 代表 | 写法                                |
  | -- | --------------------------------- |
  | 月份 | 1,01,Jan,January                  |
  | 日  | 2,02,\_2                          |
  | 时  | 3,03,15,PM,pm,AM,am               |
  | 分  | 4,04                              |
  | 秒  | 5,05                              |
  | 年  | 06,2006                           |
  | 时区 | -07,-0700,Z0700,Z07:00,-07:00,MST |
  | 周几 | Mon,Monday                        |

  * **比如小时的表示**(原定义是下午 3 时，也就是 15 时)

    3 ⽤ 12 小时制表⽰，去掉前导 0

    03 ⽤ 12 小时制表⽰，保留前导 0

    15 ⽤ 24 小时制表⽰，保留前导 0

    03pm ⽤ 24 小时制 am/pm 表⽰上下午表⽰，保留前导 0

    3pm ⽤ 24 小时制 am/pm 表⽰上下午表⽰，去掉前导 0

  * **又比如月份**

    1 数字表⽰月份，去掉前导 0

    01 数字表⽰月份，保留前导 0

    Jan 缩写单词表⽰月份

    January 全单词表⽰月份

## 举例

| 待转换数据        | 转换语句                                           | 输出结果                 |
| ------------ | ---------------------------------------------- | -------------------- |
| `1560391089` | `timeConvert(1560391089, '2006_01_02/3/4/05')` | `2019_06_13/9/58/09` |
