js将时间戳转换成日期格式-陈远波
var timestamp =1539598555000;//时间戳 //时间戳转换成time格式
function timestampToTime(timestamp) {
var date = new Date(timestamp );//时间戳为10位需*1000,时间戳为13位的话不需乘1000
Y = date.getFullYear() + '-';
M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
D = date.getDate() + ' ';
h = date.getHours() + ':';
m = date.getMinutes() + ':';
s = date.getSeconds();
return Y+M+D+h+m+s;
}
var dateTime =timestampToTime(timestamp)//转换时间戳
alert(dateTime);
效果如下:
js将时间戳转换成日期格式-陈远波的更多相关文章
- js angular 时间戳转换成日期格式 年月日 yyyy-MM-dd
昨天写项目,要把时间戳转换成日期格式发给后端 我就去网上找 看到的一些都不是我想要的 索性自己就写了一个如图 下面是angular 模式 $scope.getMyDate = function(str ...
- js中时间戳转换成时间格式
js中时间戳转换成时间格式, // 时间戳转换成时间格式 var formatDate = function(date){ date = new Date(date); var y=date.getF ...
- vue 将时间戳转换成日期格式 (一)
(1)创建一个处理时间格式的js,内容如下: ../../utils/formatDate.js export function formatDate(date, fmt) { if (/(y+)/. ...
- jqgrid 时间戳转换成日期格式
原文 :http://blog.csdn.net/caoyuancsdn/article/details/52984524 Java script 接收到的时间参数是时间戳*1000 functio ...
- javaScript中将时间戳转换成日期格式
function DateFormt(time, format) { ); var o = { , "d+": testDate.getDate(), "h+" ...
- js时间戳转成日期格式
将时间戳转换成日期格式:// 简单的一句代码var date = new Date(时间戳); //获取一个时间对象 注意:如果是uinx时间戳记得乘于1000.比如php函数time()获得的时间戳 ...
- 时间戳转换成日期的js
在项目开发过程中,我们常常需要把时间戳转换成日期.下面这个是我一直使用的js方法,希望能帮助到有需要的朋友.大家如果有更好的方法,请多多指教! js代码如下: //时间戳转换成日期 function ...
- javascript时间戳转换成指定格式的日期
//时间戳转换成指定格式的日期DateTool.IntDatetimeTo = function(time, format){ var testDate = new Date(time); ...
- moment使用,把某个时间时间戳转换成日期
1.某个时间时间戳转换成日期 moment(时间戳 ).format("YYYYMMDD") 2.获取某个日期当月的最后一天 moment(“2019-04-05”).endO ...
随机推荐
- vue中使用animate.css
一:使用animate.css的使用 1.安装npm install animate.css --save 2.在main.js中引入import animate from 'animate.css' ...
- 人工智能日常应用举例-nlp+视觉(听说看)
- 分布式理论(一) —— CAP 定理
目录: 什么是 CAP 定理 为什么只能 3 选 2 能不能解决 3 选 2 的问题 引用 1. 什么是 CAP 定理 2000 年的时候,Eric Brewer 教授提出了 CAP 猜想,2年后,被 ...
- 【转载】H5页面列表的无线滚动加载(前端分页)
本代码基于Vue的架构 1.首先,要滚动的内容放在一个‘id=box’ 的div里,对div进行scroll事件的监听 <div id="box" class="m ...
- [转]论magento1和magento2的速度性能优化问题
本文转自:http://www.360magento.com/blog/magento-speed-up/ magento从2007年发展至今,也经历了十余年的磨练,如今也迎来了magento的换代产 ...
- [转]webpack4.0.1安装问题和webpack.config.js的配置变化
本文转自:https://blog.csdn.net/jiang7701037/article/details/79403637 The CLI moved into a separate packa ...
- Oracle左连接、右连接、全外连接以及(+)号用法
1.准备工作 Oracle 外连接(OUTER JOIN)包括以下: 左外连接(左边的表不加限制) 右外连接(右边的表不加限制) 全外连接(左右两表都不加限制) 对应SQL:LEFT/RIGHT/F ...
- Tomcat7.0安装配置详细(图文)
说明:Tomcat服务器上一个符合J2EE标准的Web服务器,在tomcat中无法运行EJB程序,如果要运行可以选择能够运行EJB程序的容器WebLogic,WebSphere,Jboss等Tomca ...
- Java基础——数组
一.大数据 如果基本的整型和浮点型精度不能够满足需求,那么可以使用java.math包含中的两个类:BigInteger和BigDecimal. 这两个类处理包含任意长度数字序列的数值.BigInte ...
- Code Signal_练习题_evenDigitsOnly
Check if all digits of the given integer are even. Example For n = 248622, the output should beevenD ...