当前位置:网站首页>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 |
边栏推荐
- js garbage collection mechanism
- CobalStrike(CS)基础超级详细版
- Interface test practice | Detailed explanation of the difference between GET / POST requests
- 【Harmony OS】【ARK UI】Date 基本操作
- Bubble sort in c language structure
- MySQL 出现 The table is full 的解决方法
- 直播|StarRocks 技术内幕 :低基数全局字典优化
- 计组错题集
- 记录一些遇见的bug——mapstruct和lombok同时使用时,转换实体类时数据丢失问题
- 【Harmony OS】【FAQ】鸿蒙问题合集1
猜你喜欢

常见荧光染料修饰多种基团及其激发和发射波长数据一览数据

Redis缓存雪崩、缓存穿透、缓存击穿

t conditional judgment statement and if loop

mysql 创建索引的三种方式

10.预测房价:回归问题

Windows 安装PostgreSQL

MySql 创建索引

Online password generator tool recommendation

GIS数据漫谈(六)— 投影坐标系统

Interface test practice | Detailed explanation of the difference between GET / POST requests
随机推荐
Can Oracle EMCC be installed independently?Or does it have to be installed on the database server?
closures in js
打破传统电商格局,新型社交电商到底有什么优点?
中断系统需要解决的问题
Jmeter 模拟多用户登录的两种方法
【Harmony OS】【ArkUI】ets开发 图形与动画绘制
DFS's complement to pruning
excerpt from compilation book
EssilorLuxottica借助Boomi的智能集成平台实现订单处理的现代化
技术分享 | 接口自动化测试中如何对xml 格式做断言验证?
三丁基-巯基膦烷「tBuBrettPhos Pd(allyl)」OTf),1798782-17-8
深圳线下报名|StarRocks on AWS:如何对实时数仓进行极速统一分析
Dialog manager in the fourth chapter: the dialog message loop
私域流量引流方法?分享购火爆的商业模式,你值得拥有
CyberArk被评为2022年Gartner特权访问管理魔力象限领导者
Concepts and Methods of Exploratory Testing
LeetCode算法日记:面试题 03.04. 化栈为队
2022河南萌新联赛第(四)场:郑州轻工业大学 G - 迷宫
8.电影评论分类:二分类问题
7.Keras开发简介