当前位置:网站首页>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 |
边栏推荐
- 【Harmony OS】【ArkUI】ets开发 基础页面布局与数据连接
- 【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability
- js garbage collection mechanism
- 如何利用 Flutter 实现炫酷的 3D 卡片和帅气的 360° 展示效果
- 私域流量引流方法?分享购火爆的商业模式,你值得拥有
- Kotlin-Flow常用封装类:StateFlow的使用
- I ported GuiLite to STM32F4 board
- 链动2+1模式简单,奖励结构丰厚,自主裂变?
- 【Harmony OS】【ARK UI】Date 基本操作
- 5.回顾简单的神经网络
猜你喜欢
随机推荐
OpenFOAM提取等职面并计算面积
OpenFOAM extracts equivalency and calculates area
直播|StarRocks 技术内幕 :低基数全局字典优化
普乐蛙VR台风体验馆厂家VR防震减灾模拟VR沉浸式体验设备
移动流量的爆发式增长,社交电商如何选择商业模式
【Harmony OS】【ARK UI】Date 基本操作
富瑞宣布战略交易,以简化运营,持续专注于打造领先的独立全服务型全球投行公司
2022 the first of the new league henan (4) : zhengzhou university of light industry G - maze
【Harmony OS】【FAQ】鸿蒙问题合集1
Interface Test Framework Practice | Process Encapsulation and Test Case Design Based on Encrypted Interface
Technology Sharing | How to do assertion verification for xml format in interface automation testing?
Concepts and Methods of Exploratory Testing
Practical application of WebSocket
Record some bugs encountered - when mapstruct and lombok are used at the same time, the problem of data loss when converting entity classes
接口测试框架实战(三)| JSON 请求与响应断言
RequestContextHolder
建立树形结构
用户密码加密工具
Flink状态
Interface test practice | Detailed explanation of the difference between GET / POST requests








