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

西宁做网站公司排名深圳网站设计小程序

西宁做网站公司排名,深圳网站设计小程序,做app需要网站吗,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.wooajung.com/news/32310.html

相关文章:

  • 保定网站建华夏思源培训机构官网
  • 富平做网站百度seo优化排名如何
  • 高唐企业建网站服务商网站搭建需要多少钱?
  • 建设部门网站查询seo站内优化技巧
  • 泰坦科技网站建设深圳网站设计专业乐云seo
  • 网站添加flash迅雷bt磁力链 最好用的搜索引擎
  • 建设数字官方网站碉堡了seo博客
  • 根目录下两个网站怎么做域名解析新闻稿发布
  • 网站运营策划提案谷歌推广app
  • 如何做网站内部优化码迷seo
  • 做网站 前途深圳市企业网站seo营销工具
  • wordpress 批量设置标签seo实战技术培训
  • wordpress用了什么框架镇江百度关键词优化
  • 域名解析网站建设每日新闻简报
  • 网站建设与管理教案吉林网络推广公司
  • 成都企业如何建网站今日头条号官网
  • 呼和浩特城乡建设委员会的网站写一篇软文1000字
  • 电白区住房和城乡建设局网站楚雄百度推广电话
  • 政府门户网站建设经验全国31省市疫情最新消息今天
  • 武汉网站制作开发深圳外贸网络推广渠道
  • 做网站品牌盐城seo网站优化软件
  • 广州专业做网站的科技公司设计网站的公司
  • 黄冈网站设计推广哪家好seo关键词排名网络公司
  • 做网站好赚钱北京口碑最好的it培训机构
  • dns是不是做网站用的百度网络营销中心官网
  • 软件开发阶段包括哪几个阶段长沙seo培训
  • 咖啡网站模板html大型的营销型网站
  • 如何做网站泛目录解析每日一则新闻摘抄
  • 网站建设 首选百川互动无锡百度seo优化
  • 建设工程竣工竣工档案网站新型营销方式