當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript dateformat類代碼示例

本文整理匯總了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}`);
	}
開發者ID:ha-dai,項目名稱:Misskey,代碼行數:4,代碼來源:logger.ts

示例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,
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:dateformat-tests.ts

示例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);
     }
 });
開發者ID:zabel-xyz,項目名稱:plsql-language,代碼行數:11,代碼來源:pldoc.controller.ts

示例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);
     }
   );
 })
開發者ID:M-O-S-E-S,項目名稱:mgm,代碼行數:21,代碼來源:ConsoleHandler.ts


注:本文中的dateformat類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。