You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
# FineUI中如何格式化输出日期
|
|
|
|
|
|
|
|
`BI.print(date,formatStr)`
|
|
|
|
|
|
|
|
如果你不知道用什么,那么直接`%Y-%X-%d %H:%M:%S`
|
|
|
|
|
|
|
|
约定当前日期为2022年十月八日
|
|
|
|
|
|
|
|
## 输出基本年月日格式
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
BI.print(BI.getDate(), "%Y-%X-%d") // '2022-10-08'
|
|
|
|
BI.print(BI.getDate(), "%Y-%x-%e") // '2022-10-08'
|
|
|
|
BI.print(BI.getDate(), "%X/%d/%Y") // '10/08/2022'
|
|
|
|
```
|
|
|
|
|
|
|
|
## 输出时分秒格式
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
BI.print(BI.getDate(), "%H:%M:%S") // '16:14:26'
|
|
|
|
BI.print(BI.getDate(), "%I:%M:%S") // '04:14:26'
|
|
|
|
BI.print(BI.getDate(), "%k:%M:%S") // '16:14:26'
|
|
|
|
BI.print(BI.getDate(), "%l:%M:%S") // '4:14:26'
|
|
|
|
```
|
|
|
|
|
|
|
|
## AM与PM区分
|
|
|
|
```javascript
|
|
|
|
BI.print(BI.getDate(), "%l:%M:%S %p") // '4:26:12 PM'
|
|
|
|
BI.print(BI.getDate(), "%l:%M:%S %P") // '4:26:12 pm'
|
|
|
|
```
|
|
|
|
|
|
|
|
## 星期
|
|
|
|
```javascript
|
|
|
|
BI.print(BI.getDate(), "%Y-%X-%d %u") // '2022-10-08 7' the day of the week (range 1 to 7, 1 = MON)
|
|
|
|
BI.print(BI.getDate(), "%Y-%X-%d %w") // '2022-10-08 6' the day of the week (range 0 to 6, 0 = SUN)
|
|
|
|
```
|
|
|
|
|
|
|
|
## 每年的第几周
|
|
|
|
```javascript
|
|
|
|
BI.print(BI.getDate(), "%Y-%W") // '2022-40'
|
|
|
|
```
|
|
|
|
|
|
|
|
## 季度
|
|
|
|
```javascript
|
|
|
|
BI.print(BI.getDate(), "%Y-%Q") // '2022-4'
|
|
|
|
BI.print(BI.getDate(), "%Y-%q") // '2022-04'
|
|
|
|
```
|