当前位置:网站首页>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 |
边栏推荐
- BIOTIN ALKYNE CAS:773888-45-2价格,供应商
- 接口测试框架实战 | 流程封装与基于加密接口的测试用例设计
- 索引创建、删除与使用
- 2022/08/02 学习笔记 (day22) 多线程
- 2022 the first of the new league henan (4) : zhengzhou university of light industry G - maze
- 2022河南萌新联赛第(四)场:郑州轻工业大学 G - 迷宫
- 获取Ip工具类
- Live | StarRocks technology insider: low base dictionary global optimization
- 自组织是管理者和成员的双向奔赴
- 数字孪生园区场景中的坐标知识
猜你喜欢
打破传统电商格局,新型社交电商到底有什么优点?
工程制图点的投影练习
OpenFOAM extracts equivalency and calculates area
深圳线下报名|StarRocks on AWS:如何对实时数仓进行极速统一分析
GIS数据漫谈(五)— 地理坐标系统
【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability
I ported GuiLite to STM32F4 board
Interface Test Framework Practice | Process Encapsulation and Test Case Design Based on Encrypted Interface
MySql 创建索引
Dialog manager in the fourth chapter: the dialog message loop
随机推荐
深圳线下报名|StarRocks on AWS:如何对实时数仓进行极速统一分析
MCM箱模型建模方法及大气O3来源解析
Practical application of WebSocket
Where is the value of testers
GIS数据漫谈(六)— 投影坐标系统
数值类型转换02
【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability
5.回顾简单的神经网络
2022河南萌新联赛第(四)场:郑州轻工业大学 G - 迷宫
2022河南萌新联赛第(四)场:郑州轻工业大学 E - 睡大觉
Two ways to simulate multi-user login in Jmeter
Browser listens for tab closing
Interface testing framework combat (3) | JSON request and response assertion
2022 the first of the new league henan (4) : zhengzhou university of light industry G - maze
v-text指令:设置标签内容
OSI的分层特点、传输过程与三次握手、四次挥手、tcp与udp包头的描述
三丁基-巯基膦烷「tBuBrettPhos Pd(allyl)」OTf),1798782-17-8
mysql bool盲注
Bubble sort in c language structure
RequestContextHolder