当前位置: 首页 > news >正文

专业建设网站建站音乐网站设计外国

专业建设网站建站,音乐网站设计外国,wordpress系统怎么样,沈阳网站关键词设置系统时间 本模块用来设置、获取当前系统时间,设置、获取当前系统日期和设置、获取当前系统时区。 说明: 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 导入模块 import systemTime …

设置系统时间

本模块用来设置、获取当前系统时间,设置、获取当前系统日期和设置、获取当前系统时区。

icon-note.gif 说明: 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。

导入模块

import systemTime from '@ohos.systemTime';

systemTime.setTime

setTime(time : number, callback : AsyncCallback) : void

设置系统时间。

需要权限: ohos.permission.SET_TIME

系统能力: SystemCapability.Miscservices.Time

参数:

参数名类型必填说明
timenumber目标时间戳(ms)。
callbackAsyncCallback回调函数,可以在回调函数中处理接口返回值。

示例:

// time对应的时间为2021-01-20 02:36:25
var time = 1611081385000;
systemTime.setTime(time, (error, data) => {if (error) {console.error(`failed to systemTime.setTime because ` + JSON.stringify(error));return;}console.log(`systemTime.setTime success data : ` + JSON.stringify(data));
});

systemTime.setTime

setTime(time : number) : Promise

设置系统时间。

需要权限: ohos.permission.SET_TIME

系统能力: SystemCapability.MiscServices.Time

参数:

参数名类型必填说明
timenumber目标时间戳(ms)。

返回值:

类型说明
Promise返回的异步回调函数。

示例:

// time对应的时间为2021-01-20 02:36:25
var time = 1611081385000;
systemTime.setTime(time).then((data) => {console.log(`systemTime.setTime success data : ` + JSON.stringify(data));
}).catch((error) => {console.error(`failed to systemTime.setTime because ` + JSON.stringify(error));
});

systemTime.getCurrentTime8+

getCurrentTime(isNano?: boolean, callback: AsyncCallback): void

获取自 Unix 纪元以来经过的时间,使用callback形式返回结果。

系统能力: SystemCapability.MiscServices.Time

参数:

参数名类型必填说明
isNanoboolean如果是true,返回纳秒数;否则返回毫秒数。
callbackAsyncCallback回调函数,返回自 Unix 纪元以来经过的时间。

示例:

systemTime.getCurrentTime(true, (error, data) => {if (error) {console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error));return;}console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data));
});

systemTime.getCurrentTime8+

getCurrentTime(isNano?: boolean): Promise

获取自 Unix 纪元以来经过的时间,使用Promise形式返回结果。

系统能力: SystemCapability.MiscServices.Time

参数:

参数名类型必填说明
isNanoboolean如果是true,返回纳秒数;否则返回毫秒数。

返回值:

类型说明
Promise以Promise形式返回结果,返回自 Unix 纪元以来经过的时间。

示例:

systemTime.getCurrentTime().then((data) => {console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data));
}).catch((error) => {console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error));
});

systemTime.getRealActiveTime8+

getRealActiveTime(isNano?: boolean, callback: AsyncCallback): void

获取自系统启动以来经过的时间,不包括深度睡眠时间,使用callback形式返回结果。

系统能力: SystemCapability.MiscServices.Time

参数:

参数名类型必填说明
isNanoboolean如果是true,返回纳秒数;否则返回毫秒数。
callbackAsyncCallback回调函数,返回自系统启动以来但不包括度睡眠时间经过的时间。

示例:

systemTime.getRealActiveTime(true, (error, data) => {if (error) {console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error));return;}console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data));
});

systemTime.getRealActiveTime8+

getRealActiveTime(isNano?: boolean): Promise

获取自系统启动以来经过的时间,不包括深度睡眠时间,使用Promise形式返回结果。

系统能力: SystemCapability.MiscServices.Time

参数:

参数名类型必填说明
isNanoboolean如果是true,返回纳秒数;否则返回毫秒数。

返回值:

类型说明
Promise以Promise形式返回结果,返回自系统启动以来经过的时间,但不包括深度睡眠时间。

示例:

systemTime.getRealActiveTime().then((data) => {console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data));
}).catch((error) => {console.error(`failed to systemTime.getRealActiveTime because ` + JSON.stringify(error));
});

systemTime.getRealTime8+

getRealTime(callback: AsyncCallback): void

获取自系统启动以来经过的时间,包括深度睡眠时间,使用callback形式返回结果。

系统能力: SystemCapability.MiscServices.Time

参数:

参数名类型必填说明
isNanoboolean如果是true,返回纳秒数;否则返回毫秒数。
callbackAsyncCallback回调函数,返回自系统启动以来经过的时间,包括深度睡眠时间。

示例:

systemTime.getRealTime(true, (error, data) => {if (error) {console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error));return;}console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data));
});

systemTime.getRealTime8+

getRealTime(): Promise

获取自系统启动以来经过的时间,包括深度睡眠时间,使用Promise形式返回结果。

系统能力: SystemCapability.MiscServices.Time

参数:

参数名类型必填说明
isNanoboolean如果是true,返回纳秒数;否则返回毫秒数。

返回值:

类型说明
Promise以Promise形式返回结果,返回自系统启动以来经过的时间,包括深度睡眠时间。

示例:

systemTime.getRealTime().then((data) => {console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data));
}).catch((error) => {console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error));
});

systemTime.setDate

setDate(date: Date, callback: AsyncCallback): void

设置系统日期,使用callback形式返回结果。

需要权限: ohos.permission.SET_TIME

系统能力: SystemCapability.MiscServices.Time

参数:

参数名类型必填说明
dateDate目标日期。
callbackAsyncCallback回调函数,可以在回调函数中处理接口返回值。

示例:

var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data,(error, data) => {       if (error) {            console.error('failed to systemTime.setDate because ' + JSON.stringify(error));           return;       
}        console.info('systemTime.setDate success data : ' + JSON.stringify(data));    
});

systemTime.setDate

setDate(date: Date): Promise

设置系统日期,使用Promise形式返回结果。

需要权限: ohos.permission.SET_TIME

系统能力: SystemCapability.MiscServices.Time

参数:

参数名类型必填说明
dateDate目标日期。

返回值:

类型说明
Promise返回的异步回调函数。

示例:

var data = new Date("October 13, 2020 11:13:00"); 
systemTime.setDate(data).then((value) => {        console.log(`systemTime.setDate success data : ` + JSON.stringify(value));    
}).catch((error) => {        console.error(`failed to systemTime.setDate because: ` + JSON.stringify(error));
});

systemTime.getDate8+

getDate(callback: AsyncCallback): void

获取当前系统日期,使用callback形式返回结果。

系统能力: SystemCapability.MiscServices.Time

参数:

参数名类型必填说明
callbackAsyncCallback回调函数,返回当前系统日期。

示例:

systemTime.getDate((error, data) => {if (error) {console.error(`failed to systemTime.getDate because ` + JSON.stringify(error));return;}console.log(`systemTime.getDate success data : ` + JSON.stringify(data));
});

systemTime.getDate8+

getDate(): Promise

获取当前系统日期,使用Promise形式返回结果。

系统能力: SystemCapability.MiscServices.Time

返回值:

类型说明
Promise以Promise形式返回结果,返回当前系统日期。

示例:

systemTime.getDate().then((data) => {console.log(`systemTime.getDate success data : ` + JSON.stringify(data));
}).catch((error) => {console.error(`failed to systemTime.getDate because ` + JSON.stringify(error));
});

systemTime.setTimezone

setTimezone(timezone: string, callback: AsyncCallback): void

设置系统时区。

需要权限: ohos.permission.SET_TIME_ZONE

系统能力: SystemCapability.MiscServices.Time

参数:

参数名类型必填说明
timezonestring系统时区。
callbackAsyncCallback回调函数,可以在回调函数中处理接口返回值。

示例:

systemTime.setTimezone('Asia/Shanghai', (error, data) => {       if (error) {          console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error));         return;       }       console.info('SystemTimePlugin systemTime.setTimezone success data : ' + JSON.stringify(data)); 
});

systemTime.setTimezone

setTimezone(timezone: string): Promise

设置系统时区。

需要权限: ohos.permission.SET_TIME_ZONE

系统能力: SystemCapability.MiscServices.Time

参数:

参数名类型必填说明
timezonestring系统时区。

返回值:

类型说明
Promise返回的异步回调函数。

示例:

systemTime.setTimezone('Asia/Shanghai').then((data) => {        console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data));     
}).catch((error) => {        console.error(`failed to systemTime.setTimezone because: ` + JSON.stringify(error));    
});

systemTime.getTimezone8+

getTimezone(callback: AsyncCallback): void

获取系统时区,使用callback形式返回结果。

系统能力: SystemCapability.MiscServices.Time

参数:

参数名类型必填说明
callbackAsyncCallback回调函数,返回系统时区。

示例:

systemTime.getTimezone((error, data) => {if (error) {console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error));return;}console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data));
});

systemTime.getTimezone8+

getTimezone(): Promise

获取系统时区,使用Promise形式返回结果。

系统能力: SystemCapability.MiscServices.Time

返回值:

类型说明
Promise以Promise形式返回结果,返回系统时区。

在这里插入图片描述

示例:

systemTime.getTimezone().then((data) => {console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data));
}).catch((error) => {console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error));
});
http://www.yayakq.cn/news/609426/

相关文章:

  • 怎么建设微网站网站标签设置
  • 北京建设工程联合验收网站设计精美的国外网站
  • 沈阳网站seo优化哪家好app推广是什么意思
  • cvm服务器做网站湛江网站的建设
  • 长沙手机模板建站网站开发类参考文献
  • wordpress the7.3企业网站优化兴田德润
  • 微信公众账号申请网站吗php网站开发答案
  • 专业做网站的公司保定公司网站运营维护单位
  • 青州市建设局网站开发一个网站做公司内部用
  • 汕头企业网站软件开发需要的软件
  • 购物网站 建站服务纯静态网站怎样
  • 长宁手机网站建设成都设计电商网站
  • 百度网站两两学一做心得体会免费 wordpress主题
  • 潍坊 网站免费软件下载平台
  • 网站建设及推广培训班简述建设iis网站的基本过程
  • 各大网站网址网站开发 合同范本
  • 还有人用asp做网站吗网站开发_运行及维护
  • 北京鑫旺路桥建设有限公司网站建设通属于什么网站
  • 上海建设官方网站视频拍摄剪辑岗位职责及要求
  • 网站的安全维护重庆网站建设找珊瑚云
  • 网站怎么被黑wordpress 缩略图作用
  • 建外贸网站哪个好广告设计公司需要什么设备
  • 学企业网站开发昆明app制作公司在哪里
  • 网站建设服务商 需要什么主机ionic做网站
  • 家居企业网站建设如何合肥网站排名提升
  • 大气红色网站wordpress上传到服务器如何解压缩
  • 网站开发技术是上海市网站设计
  • 乐昌门户网站中国网站建设公司有哪些内容
  • 哪个网站可以做鞋鉴定做技术类网站赚钱吗
  • 网站建设开场白怎么说中铁建设集团有限公司领导名单