JS in ,Date Type is a common type ; Moment.js Is a common process js Date Third party package for ;
This paper deals with js Date Type and moment.js To sort out and summarize the common usage of ;
1、Date()
Output Date(), give the result as follows 
Got Date Object is a complex format , In many cases, we need to intercept the time, minutes and seconds of the month, day, year, and then splice them to get the format we need
getFullYear() Returns a four digit year
getMonth Return to the month (0-11)
getDay Return days (1 ~ 31)
getHours Return hours (0-23)
getMinutes Return to minutes (0-59)
getSeconds Return seconds (0-59)
getTime Return timestamp 
So I want to go through Date() Object to get the formatted date and time , You need the above method to intercept the year, day, hour, minute and second, and then splice them to get the formatted date and time
2、Moment.js
moment.js Is dealing with js Date Third party package for , Official website :http://momentjs.cn/
Output moment(), give the result as follows 
The output value is an object , from m Data such as year, month, day, hour, minute, second, etc. are obtained in :
It is formatted directly , therefore moment() More convenient !
当前位置:网站首页>Common methods of JS date and time
Common methods of JS date and time
2022-06-29 03:39:00 【Xiaomeng】
边栏推荐
- 19.03 容器的说明和简单应用例续
- Do you feel confused when you study at three in the morning?
- FortiGate firewall filters the specified session and cleans it up
- Set hardware breakpoint instruction for ejtag under the PMON of the Godson development board
- Implementing mqtt communication with PHP
- Grafana入门教程
- Yyds dry inventory difference between bazel and gradle tools
- DevOps笔记-05:IT行业中BA、SM、PO、PM、PD、Dev、Ops、QA都是什么角色
- leetcode:560. Subarray with and K
- leetcode:304. 二维区域和检索 - 矩阵不可变
猜你喜欢

MySQL advanced SQL statement (Part 2)

Connect error: no route to host (errno:113)

Go implements distributed locks
![相同的树[从部分到整体]](/img/2d/997b9cb9cd4f8ea8620f5a66fcf00a.png)
相同的树[从部分到整体]

【TcaplusDB知识库】TcaplusDB-tcaplusadmin工具介绍

88.(cesium篇)cesium聚合图

Probe into metacosmic storage, the next explosive point in the data storage market?

19.03 vessel description and simple application examples continued

Digital twin application of smart Park Based on Web GIS aerial photography

2D人体姿态估计 - DeepPose
随机推荐
Error: schema validation failed with the following error: the data path '' should not have other properties (projects)
[tcapulusdb knowledge base] Introduction to tcapulusdb table data caching
Etcd tutorial - Chapter 6 etcd core API V3
Concise words tell about technical people who must master basic IT knowledge and skills. Part 1
Yyds dry inventory everything a primary developer should know about activity
vim配置与使用
【TcaplusDB知识库】查看tcapdir目录服务器
【TcaplusDB知识库】TcaplusDB数据导入介绍
An internal error occurred during: 'Retrieving archetypes:'.
Tupu software intelligent energy integrated management and control platform
Connect error: no route to host (errno:113)
20款IDEA 神级插件 效率提升 30 倍,写代码必备
Zigzag sequence traversal of binary tree [one of layered traversal methods - > preorder traversal +level]
MySQL Varcahr to int
Counter analysis of the parameter anti content in the backstage of the # yyds dry goods inventory # knife fight shop
Do you feel confused when you study at three in the morning?
【TcaplusDB知识库】TcaplusDB限制条件介绍
[tcapulusdb knowledge base] tcapulusdb technical support introduction
MySQL advanced SQL statement (Part 2)
DevOps笔记-05:IT行业中BA、SM、PO、PM、PD、Dev、Ops、QA都是什么角色