跳到主要内容

bn.dateTimeFormat

dateTimeFormat(timestamp, options): string

description format date time.

remark supported jssdk >= 4.36.0

example

bn.dateTimeFormat(1659971700000, {
year: 'numeric',
month: 'short',
day: 'numeric'
})
// => "Aug 8, 2022"

bn.dateTimeFormat(1659971700000, {
hour: 'numeric',
minute: 'numeric',
})
// => "11:15 PM"

Parameters

NameType
timestampnumber
optionsDateTimeFormatOptions

Returns

string

string

Interface: DateTimeFormatOptions

NameTypeDescription
weekday?"long" | "short" | "narrow"
year?"numeric" | "2-digit"
month?"long" | "short" | "narrow" | "numeric" | "2-digit"
day?"numeric" | "2-digit"
hour?"numeric" | "2-digit"
minute?"numeric" | "2-digit"
second?"numeric" | "2-digit"
dateStyle?"medium" | "long" | "short" | "full"
timeStyle?"medium" | "long" | "short" | "full"