当前位置:网站首页>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 |
边栏推荐
- Interface test framework combat (1) | Requests and interface request construction
- 常见亲脂性细胞膜染料DiO, Dil, DiR, Did光谱图和实验操作流程
- 【精讲】利用原生js实现todolist
- Redis缓存雪崩、缓存穿透、缓存击穿
- Kotlin-Flow common encapsulation class: the use of StateFlow
- 13.机器学习基础:数据预处理与特征工程
- unity2D横板游戏教程6-敌人AI以及受击动画
- 浏览器监听标签页关闭
- The flink sql task is changed, and after adding several fields to the sql, an error occurs when restoring from the previously saved savepoint.
- 【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability
猜你喜欢
随机推荐
索引创建、删除与使用
Interface Test Framework Practice (4) | Get Schema Assertion
富瑞宣布战略交易,以简化运营,持续专注于打造领先的独立全服务型全球投行公司
Shell编程的条件语句
online test paper concept
自组织是管理者和成员的双向奔赴
多肽介导PEG磷脂——靶向功能材料之DSPE-PEG-RGD/TAT/NGR/APRPG
I ported GuiLite to STM32F4 board
记录一些遇见的bug——mapstruct和lombok同时使用时,转换实体类时数据丢失问题
DDL操作数据库、表、列
社交电商:流量红利已尽,裂变营销是最低成本的获客之道
获取Ip工具类
数据库基本概述与SQL概述
Interface test practice | Detailed explanation of the difference between GET / POST requests
常见亲脂性细胞膜染料DiO, Dil, DiR, Did光谱图和实验操作流程
在线密码生成工具推荐
OpenFOAM提取等职面并计算面积
【精讲】利用原生js实现todolist
私域流量引流方法?分享购火爆的商业模式,你值得拥有
BIOTIN ALKYNE CAS:773888-45-2价格,供应商









