本文整理匯總了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);
}
);
})