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

西宁做网站公司排名怎么做个人网页

西宁做网站公司排名,怎么做个人网页,网站公司做销售怎么样,旅游网站建设的费用明细设置系统时间 本模块用来设置、获取当前系统时间,设置、获取当前系统日期和设置、获取当前系统时区。 说明: 本模块首批接口从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.15wanjia.com/news/18473.html

相关文章:

  • 做项目的编程网站百度推广关键词
  • wordpress网站底部导航代码江苏seo推广
  • 长春网站推广优化公司百度站长工具排名
  • 用vs2013做网站案例网站优化排名服务
  • 深圳品牌网站建设个人网站模板免费下载
  • 中为网站建设怎么提交百度收录
  • 宁波网络公司报价外包seo公司
  • 中山网站建设文化价格网络推广比较经典和常用的方法有
  • 深圳网站建设公司模板学习软件的网站
  • 想自己做个网站怎么做百度推广客户端电脑版
  • 网站开发论文研究方法东莞互联网公司排名
  • 广西自治区集约化网站建设要求国际军事最新消息今天
  • 网站建设沧州怎么在网上做广告宣传
  • 营销型企业网站分析与诊断的步骤网站建设品牌公司
  • 百度推广区域代理硬件优化大师
  • 无人机公司网站建设seo整站优化更能准确获得客户
  • 深圳网站建设企业名录免费网站免费
  • 上海网站 备案谷歌seo网站运营
  • 网站上的vr全景是怎么做的兰州网络推广公司哪家好
  • 吉林省人民政府办公厅官网网站seo站外优化
  • 网站定制电话江苏seo团队
  • 不参与网站建设的弊端企业qq官网
  • 连云港网站建设bw263桂平seo快速优化软件
  • 广西做网站的公司有哪些文登seo排名
  • wordpress备份博客图片seopc流量排行榜企业
  • 上海松江做网站公司服装品牌营销策划方案
  • 网站建设有什么证长沙seo男团
  • 邢台市建设局官方网站友情链接交换平台
  • 苏州建站公司选苏州聚尚网络百度百科官网
  • 杭州做网站的优质公司哪家好自己的产品怎么推广