本文整理汇总了TypeScript中dateformat类的典型用法代码示例。如果您正苦于以下问题:TypeScript dateformat类的具体用法?TypeScript dateformat怎么用?TypeScript dateformat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了dateformat类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: log
public static log(level: string, message: string): void {
const time = dateformat(new Date(), 'HH:MM:ss');
console.log(`[${time} ${level}] ${message}`);
}
示例2: Date
/**
* https://github.com/felixge/node-dateformat#usage
*/
import * as dateFormat from 'dateformat'
const now = new Date()
// Basic usage
dateFormat(now, 'dddd, mmmm dS, yyyy, h:MM:ss TT')
// Saturday, June 9th, 2007, 5:46:21 PM
// You can use one of several named masks
dateFormat(now, 'isoDateTime')
// 2007-06-09T17:46:21
// ...Or add your own
dateFormat.masks['hammerTime'] = `HH:MM! "Can't touch this!"`
dateFormat(now, 'hammerTime')
// 17:46! Can't touch this!
// When using the standalone dateFormat function,
// you can also provide the date as a string
dateFormat('Jun 9 2007', 'fullDate')
// Saturday, June 9, 2007
// Note that if you don't include the mask argument,
// dateFormat.masks.default is used
dateFormat(now)
// Sat Jun 09 2007 17:46:21
// And if you don't include the date argument,
示例3: dateFormat
text = text.replace(this.getRegFindVarDoc(key), (match, p1, p2) => {
if (!p1 || (p1.toLowerCase() !== 'date'))
return variables[key];
else {
// replace date
if (!p2 || (p2.trim() === ''))
return variables.date.toLocaleDateString();
else
return dateFormat(variables.date, p2);
}
});
示例4: dateFormat
return new Promise<string>((resolve, reject) => {
jwt.sign(
{
Username: u.username + ' ' + u.lastname,
Scope: 'remote-console',
Exp: dateFormat(new Date().setDate(new Date().getDate() + 2), 'mm/dd/yyyy h:MM:ss'),
UserId: u.UUID,
BirthDate: new Date(u.created),
PartnerId: u.partner
},
cert,
{
algorithm: 'RS256',
noTimestamp: true
},
(err: Error, token: string) => {
if (err) return reject(err);
resolve(token);
}
);
})