当前位置:网站首页>JS converts timestamp to normal time format
JS converts timestamp to normal time format
2022-06-10 12:16:00 【000000001111】
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>js Convert timestamp to normal time format </title>
</head>
<body>
</body>
<script type="text/javascript">
// Method 1
function timestampTime(timestamp) {
var date = new Date(timestamp * 1000); // Timestamp 10 Bitwise demand *1000, Timestamp 13 You don't need to take a seat 1000
var Y = date.getFullYear() + '-';
var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
var D = date.getDate() + ' ';
var h = date.getHours() + ':';
var m = date.getMinutes() + ':';
var s = date.getSeconds();
return Y + M + D + h + m + s;
}
var time = timestampTime(1177824835);
console.log(time); //2007-04-29 13:33:55
// Method 2
var time = new Date(parseInt(1177824835) * 1000).toLocaleString().replace(/:\d{
1,2}$/,' ');
console.log(time); //2007/4/29 Afternoon 1:33
</script>
</html>

边栏推荐
- 数字经济时代,零售实体门店该何去何从
- Lufax: external technology output enables financial enterprises to achieve independent and controllable database
- Driver. JS - open source and independent interactive guidance tool library for web novices, powerful and highly customizable
- 【云图说】每个成功的业务系统都离不开APIG的保驾护航
- SLM4054独立线性锂电池充电器的芯片的学习
- JS将阿拉伯数字翻译成中文的大写数字、JS将数字转换为大写金额(整理)
- Traversing object properties of unknown type
- Massive data: the first stock of Huawei Gauss database (depth)
- Transfomer components and pytoch
- Gimp - free and open source image processing software with powerful functions, known as an excellent substitute for Photoshop
猜你喜欢
随机推荐
掌握高性能计算前,我们先了解一下它的历史
C# 均衡权重分配
STM32学习笔记(2)-USART(基础应用1)
IO文件流重复读取
0509-130 Symbol resolution failed for /oracle/app/oracle/12.2.0/db_ 1/lib/libons. So problem handling
使用Joern处理大量文件,生成PDG速度很慢的解决方法
[limited time], full of dry goods
"Yi +" open source program - Design and practice of low delay player based on webrtc
[Accessibility] Missing contentDescription attribute on image
【雲圖說】每個成功的業務系統都離不開APIG的保駕護航
Web server development, small company web development
Transfomer components and pytoch
IndexedDB 数据库的使用
In the era of digital economy, where should retail stores go
C语言最佳实践之库文件介绍(下)
js全局计时器的案例
element弹出框关闭并销毁:清空弹出里的数据缓存(整理)
Dom4j parsing XML
web服务器开发,小型公司web开发
Learning of fm4057s single lithium battery linear charging chip



![[required] analysis of the real problem](/img/36/08c752763b8b89aa60feaa4339a689.png)





