原子操作

飞道科技

@dfeidao/atom-wxapp > dt时间操作

External module: dt时间操作

Index

Functions


Functions

format

format(date: number, type: 0 | 1 | 2): string

Defined in dt/format.ts:15

将时间戳转为字符串

example:

import format from '@dfeidao/atom-wxapp/dt/format';
const time = format(1550620800000, 0);// '2019-02-20'

Parameters:

Name Type Description
date number 时间戳
type 0 | 1 | 2 转换类型,(0:yyyy-MM-dd,1:yyyy-MM-dd HH:mm:ss,2:yyyy-MM-dd HH:mm)

Returns: string


parse

parse(date: string): number

Defined in dt/parse.ts:16

将字符串转化为时间戳

example:

import parse from '@dfeidao/atom-wxapp/dt/parse';
const time = parse('2019-02-20'); // 1550620800000

Parameters:

Name Type Description
date string 自定义时间字符串

Returns: number 时间戳


prefix

prefix(str: string, len: number, separator?: string): string

Defined in dt/format.ts:41

小于几位数补0

Parameters:

Name Type Default value Description
str string - 要修改的字符串
len number - 几位数
Default value separator string "0" 补0

Returns: string