当前位置:网站首页>Harmony OS Date ano UI 】 【 】 the basic operation
Harmony OS Date ano UI 】 【 】 the basic operation
2022-08-03 04:39:00 【Huawei Developer Forum】
The time operation is a very basic operation. Today, I will describe how to get the timestamp, get the current time zone, and get the current date function.Mainly divided into: "development preparation", "api explanation", "operation effect"
1. Development preparation
The materials we need to learn are as follows
1.1[HarmonyOS] How does the Hongmeng ets project introduce third-party js libraries through npm
1.2 Jstz
1.3 Comparative ReferenceJavaScript Date Object
2, api explanation
2.1 Get the current time zone, refer to the Jstz repository
2.2 Get the current timestamp
var str= "2018-07-26";console.log(Date.parse(str)/1000+"")
2.3 To get the current time, our parameter referenceJavaScript Date ObjectInformation
3. Operation effect
3.1 All codes are as follows
import jstz from 'jstz';@[email protected] DataTimePage {private DateParse(){var str= "2018-07-26";console.log(Date.parse(str)/1000+"")}private gettime(){let time=new Date();console.log(time.getFullYear()+"year"+(time.getMonth()+1)+"month"+time.getDate()+"day")}build() {Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {Text('Get the current time zone').fontSize(50).fontWeight(FontWeight.Bold).onClick(function(){var timezone = jstz.determine();var Asia = timezone.name();console.log( Asia);})Text('convert date to timestamp').fontSize(50).fontWeight(FontWeight.Bold).backgroundColor(Color.Red).onClick(this.DateParse.bind(this))Text('Get the current log').fontSize(50).fontWeight(FontWeight.Bold).backgroundColor(Color.White).onClick(this.gettime.bind(this))}.width('100%').height('100%')}}
The effect of 3.2 is as follows
For more technical articles, please visit: https://developer.huawei.com/consumer/cn/forum/topic/0204816364037980384?fid=0102683795438680754?ha_source=zzh |
边栏推荐
- IO进程线程->线程->day5
- OpenFOAM提取等职面并计算面积
- Can Oracle EMCC be installed independently?Or does it have to be installed on the database server?
- 接口测试如何准备测试数据
- 索引创建、删除与使用
- 深圳线下报名|StarRocks on AWS:如何对实时数仓进行极速统一分析
- DFS对剪枝的补充
- 接口测试实战| GET/POST 请求区别详解
- 2022 the first of the new league henan (4) : zhengzhou university of light industry G - maze
- 社交电商:流量红利已尽,裂变营销是最低成本的获客之道
猜你喜欢
测开:项目管理模块-项目curd开发
v-text指令:设置标签内容
Dialog manager in the fourth chapter: the dialog message loop
「短视频+社交电商」营销模式爆发式发展,带来的好处有什么?
打破传统电商格局,新型社交电商到底有什么优点?
StarRocks July Community Update
Two ways to simulate multi-user login in Jmeter
Concepts and Methods of Exploratory Testing
Shell编程的条件语句
接口测试框架实战 | 流程封装与基于加密接口的测试用例设计
随机推荐
刚上线就狂吸70W粉,新型商业模式“分享购”来了,你知道吗?
How to use the interface management tool YApi?Beautiful, easy to manage, super easy to use
自组织是管理者和成员的双向奔赴
GIS数据漫谈(六)— 投影坐标系统
【软件工程之美 - 专栏笔记】35 | 版本发布:软件上线只是新的开始
「短视频+社交电商」营销模式爆发式发展,带来的好处有什么?
I ported GuiLite to STM32F4 board
Interface test framework combat (1) | Requests and interface request construction
超好用的画图工具推荐
工程制图点的投影练习
js garbage collection mechanism
11.机器学习基础:机器学习的四个分支
测试人员的价值体现在哪里
Shell之条件语句
GIS数据漫谈(五)— 地理坐标系统
社交电商:链动2+1模式,为什么能在电商行业生存那么久?
Interface test Mock combat (2) | Combined with jq to complete batch manual Mock
安装ambari
online test paper concept
中断系统需要解决的问题