当前位置:网站首页>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 |
边栏推荐
- 探索性测试的概念及方法
- 数据库基本概述与SQL概述
- 接口测试框架实战 | 流程封装与基于加密接口的测试用例设计
- Where is the value of testers
- Oracle EMCC可以独立安装吗?还是必须安装到数据库服务器上?
- Interface Test Framework Practice (4) | Get Schema Assertion
- excerpt from compilation book
- Flink状态
- Problems that need to be solved for interrupting the system
- Technology Sharing | How to do assertion verification for xml format in interface automation testing?
猜你喜欢
随机推荐
汇编书摘抄
计网试卷概念
mysql bool盲注
浏览器监听标签页关闭
MySQL 出现 The table is full 的解决方法
Shenzhen Offline Registration|StarRocks on AWS: How to conduct rapid and unified analysis of real-time data warehouses
传统企业如何转型社交电商,泰山众筹的玩法有哪些?
用户密码加密工具
安装ambari
OpenFOAM extracts equivalency and calculates area
打破传统电商格局,新型社交电商到底有什么优点?
如何利用 Flutter 实现炫酷的 3D 卡片和帅气的 360° 展示效果
深圳线下报名|StarRocks on AWS:如何对实时数仓进行极速统一分析
那些让电子工程师崩溃瞬间,你经历了几个呢?
"Obs" start pushing flow failure: the Output. The StartStreamFailed call process
MCM箱模型建模方法及大气O3来源解析
IO进程线程->线程->day5
12.机器学习基础:评估机器学习模型
用户密码验证
v-on指令:为元素绑定事件