当前位置:网站首页>获取时分秒
获取时分秒
2022-07-26 02:21:00 【背藏玫瑰】
获取时间戳
//获取时间戳
function getTime() {
const timezone = 8; // 目标时区时间,东八区 东时区正数 西市区负数
const offset_GMT = new Date().getTimezoneOffset(); // 本地时间和格林威治的时间差,单位为分钟
const nowDate = new Date().getTime(); // 本地时间距 1970 年 1 月 1 日午夜(GMT 时间)之间的毫秒数
const targetDate = new Date(
nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000
);
const time = targetDate.getTime();
return time;
}获取时间戳
Date.now()
1658748281671获取年月日时分秒
//获取年月日 时分秒
getCurrentTime() {
var myDate = new Date();
var nowDate =
myDate.getFullYear() +
"-" +
(myDate.getMonth() + 1) +
"-" +
myDate.getDate() + " "+ myDate.getHours()+ ":"+myDate.getMinutes()+':'+myDate.getSeconds()
const cunrentTime = nowDate;
return cunrentTime
},获取年月日 时分秒 和当前星期几
function time() {
var vWeek, vWeek_s, vDay;
vWeek = ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
var date = new Date();
year = date.getFullYear();
month = date.getMonth() + 1;
day = date.getDate();
hours = date.getHours();
minutes = date.getMinutes();
seconds = date.getSeconds();
vWeek_s = date.getDay();
console.log( year + "年" + month + "月" + day + "日" + "\t" + hours + ":" + minutes + ":" + seconds + "\t" + vWeek[vWeek_s]);
};
setInterval("time()", 1000);
边栏推荐
- LeetCode302场周赛第三题--裁剪数字后查询第 K 小的数字
- I came to the library applet check-in process analysis
- Yum install MySQL FAQ
- Activiti workflow gateway
- 【红队】ATT&CK - 利用BITS服务实现持久化
- How to choose cloud note tool? What can I do with cloud notes?
- 1. Mx6ul core module serial Ethernet test (VII)
- 1. Mx6ul core module use serial RTC test (XII)
- (CVPR 2019) GSPN: Generative Shape Proposal Network for 3D Instance Segmentation in Point Cloud
- Prove that perfect numbers are even
猜你喜欢
![[xxl-job] xxl-job learning](/img/2c/d3872983e4228a3ef52a9d1bef836e.png)
[xxl-job] xxl-job learning

信息系统项目管理师---第十章沟通管理和干系人管理历年考题

Sword finger offer 28. symmetric binary tree

C unit test

i. Mx6ull snvs power domain GPIO status hold verification

Acwing 379. hide and seek problem solution (minimum path non repeating point coverage)

The slow loading of the first entry page of vite local operation

Prometheus + process exporter + grafana monitor the resource usage of the process

栈题目:文件的最长绝对路径

i.MX6ULL SNVS电源域GPIO状态保持验证
随机推荐
19_ Request forms and documents
Implementation of Ti am335x industrial control module network and file system nfs
[leetcode] 32. Longest valid bracket
Primary key b+ tree, secondary index b+ tree and corresponding query process analysis
1. Mx6ul core module serial use - touch screen calibration (IX)
Is the securities account presented by qiniu true? How to open it safely and reliably?
2. Login - verification code function and saving login status
增删改查业务的快速上手
I.MX6UL核心模块使用连载-CAN、蜂鸣器测试 (十一)
3. Upload the avatar to qiniu cloud and display it
Adruino basic experimental learning (I)
Digital warehouse: on the construction practice of digital warehouse in banking industry
I.MX6UL核心模块使用连载-以太网测试 (七)
Are you still using ==0 null equal to judge null values? How much do you know about isempty and isblank
Illustration of the insertion process of b+ tree
Monitoring of debezium synchronization debezium
一款可插拔的AM335X工控模块板载wifi模块
SQL how to return all data when the input query condition is empty
Tenant issues.
[2021] [paper notes] 6G technology vision - otfs modulation technology