DateTime.format(value:int, format:string)
Parameters
Name |
Type |
Действие |
Значение по умолчанию |
value |
int |
時間 Unix timestamp |
— |
format |
string |
或作為字符串傳遞 DateTime.Format 或作為字符串傳遞 |
— |
Example
export class Main extends Indicator {
constructor() {
super();
}
onInit() {}
async onUpdate() {
const PriceType = 0,
{Time, Open} = await Bar.load([Bar.Mode.Time, Bar.Mode.Open], PriceType);
let t = Time[0];
let ThisDate = DateTime.format(t, 'YYYY.MM.DD');
this.print('ThisDate is '+ThisDate);
// 結果,例如: ThisDate is 2017.10.06
ThisDate = DateTime.format(t, 'YYYY/MM/DD');
this.print('ThisDate is '+ThisDate);
// 結果,例如: ThisDate is 2017/10/06
ThisDate = DateTime.format(t, 'DD/MM/YYYY HH:mm');
this.print('ThisDate is '+ThisDate);
// 結果,例如: ThisDate is 06/10/2017 17:56
ThisDate = DateTime.format(t, '"HH:mm:ss:SSS DD/MM/YYYY года"');
this.print('ThisDate is '+ThisDate);
// 結果 - 帶秒的時間:給定形式的毫秒和日期,例如: ThisDate is "22:33:44:777 06/10/2017 года"
}
}