当前位置:网站首页>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 practice | Detailed explanation of the difference between GET / POST requests

BIOTIN ALKYNE CAS:773888-45-2价格,供应商

mysql 创建索引的三种方式

OpenFOAM extracts equivalency and calculates area

6.神经网络剖析

StarRocks July Community Update

Where is the value of testers

社交电商:链动2+1模式,为什么能在电商行业生存那么久?

12.机器学习基础:评估机器学习模型

I ported GuiLite to STM32F4 board
随机推荐
测试人员的价值体现在哪里
GIS数据漫谈(五)— 地理坐标系统
mysql bool盲注
Two ways to simulate multi-user login in Jmeter
工程制图-齿轮
深圳线下报名|StarRocks on AWS:如何对实时数仓进行极速统一分析
在线密码生成工具推荐
Record some bugs encountered - when mapstruct and lombok are used at the same time, the problem of data loss when converting entity classes
DDL操作数据库、表、列
【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability
普乐蛙VR台风体验馆厂家VR防震减灾模拟VR沉浸式体验设备
修饰生物素DIAZO-生物素-PEG3-DBCO|重氮-生物素-三聚乙二醇-二苯基环辛炔
Interface testing framework of actual combat (2) | interface request assertion
Shell条件语句判断
Shell编程的条件语句
MCM箱模型建模方法及大气O3来源解析
MySQL 入门:Case 语句很好用
接口管理工具YApi怎么用?颜值高、易管理、超好用
三丁基-巯基膦烷「tBuBrettPhos Pd(allyl)」OTf),1798782-17-8
超好用的画图工具推荐