当前位置:网站首页>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 |
边栏推荐
- MySQL 入门:Case 语句很好用
- Redis缓存雪崩、缓存穿透、缓存击穿
- 计组错题集
- 数字化时代,企业如何建立自身的云平台与商业模式的选择?
- 探索性测试的概念及方法
- 接口和协议
- Can Oracle EMCC be installed independently?Or does it have to be installed on the database server?
- Technology Sharing | How to do assertion verification for xml format in interface automation testing?
- 接口测试框架实战(四)| 搞定 Schema 断言
- Live | StarRocks technology insider: low base dictionary global optimization
猜你喜欢
随机推荐
[Developers must see] [push kit] Collection of typical problems of push service service 2
MySQL 入门:Case 语句很好用
Jmeter 模拟多用户登录的两种方法
常见亲脂性细胞膜染料DiO, Dil, DiR, Did光谱图和实验操作流程
The flink sql task is changed, and after adding several fields to the sql, an error occurs when restoring from the previously saved savepoint.
记录一些遇见的bug——mapstruct和lombok同时使用时,转换实体类时数据丢失问题
探索性测试的概念及方法
Interface Test Framework Practice (4) | Get Schema Assertion
"Obs" start pushing flow failure: the Output. The StartStreamFailed call process
接口测试框架实战(四)| 搞定 Schema 断言
js中的闭包
excerpt from compilation book
链动2+1模式简单,奖励结构丰厚,自主裂变?
汇编题答案
中断系统需要解决的问题
浏览器监听标签页关闭
自组织是管理者和成员的双向奔赴
Bubble sort in c language structure
MySql 创建索引
C#异步和多线程









