artTemplate/template.js模板将时间戳格式化为正常的日期
1:引用<script type="text/javascript" src="../js/artTemplate/template.js"></script>
2:在正常渲染中引入方法 | timestamp: 'yyyy-MM-dd hh:mm:ss'
<div>开始时间<span>{{value.endTime | timestamp: 'yyyy-MM-dd hh:mm:ss'}}</span></div>
3:在script标签中封装方法timestamp
//template魔板处理后台时间戳转日期方法
template.helper('timestamp', function(value, format) {
var date = new Date(value);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
var h = date.getHours();
h = h < 10 ? ('0' + h) : h;
var minute = date.getMinutes();
var second = date.getSeconds();
minute = minute < 10 ? ('0' + minute) : minute;
second = second < 10 ? ('0' + second) : second;
return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
});
4:完成
artTemplate/template.js模板将时间戳格式化为正常的日期的更多相关文章
- artTemplate/template.js模板将时间格式化为正常的日期
网上提供的方法用不了 自己琢磨的 注意:ajax的异步方式必须设置成true才行,false不起作用.async: true: <script> function timestamp (v ...
- js将时间戳格式化为HH:ii:ss的格式
将时间戳格式化为 HH:ii:ss的格式 <html> <head> </head> <body> <span id="time&quo ...
- Python 将一个时间戳格式化为(格林威治时间或者本地时区时间)
时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数. 获取一个时间戳 import time times = time. ...
- jsp中/el表达式中将后台传来的时间戳格式化为年月日时分秒
sp中/el表达式中将后台传来的时间戳格式化为年月日时分秒1.引入相关标签库 <%@taglib prefix="c" uri="http://java.sun.c ...
- template.js模板工具案例
案例一 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset=&qu ...
- artTemplate 原生 js 模板语法版
在页面中引用模板引擎: <script src="dist/template-native.js"></script> 下载 表达式 <% 与 %&g ...
- template.js 模板引擎
例子: html代码: <div id="box"></div> css代码: table{ border-collapse: collapse; text ...
- python:将时间戳格式化为yyyyMMdd hh:mm:ss
import time #将10位时间戳或者13位转换为时间字符串,默认为2017-10-01 13:37:04格式 def timestamp_to_date(time_stamp, format_ ...
- js将当前时间格式化为年-月-日 时:分:秒
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
随机推荐
- poj3630 Phone List
spy on一下,发现是trie裸题,结果一交就T... 然后把cin改成scanf就A了... trie的空间一定要开足,要不然RE #include <cstdio> #include ...
- c# WebApi之身份验证:Basic基础认证
为什么需要身份认证 身份认证是为了提高接口访问的安全性,如果没有身份验证,那么任何匿名用户只要知道服务器的url,就可以随意访问服务器,从而访问或者操作数据库,这会是很恐怖的事. 什么是Basic基础 ...
- semantic ui框架学习笔记三
网格系统 基本网格 <div class="ui grid"> <div class="column"></div> < ...
- cnblogs latex公式
选项->启用数学公式支持 \begin{equation*} \begin{split} &xxx\\ &xxx\\ \end{split} \end{equation*} (\ ...
- Mysql中INSERT ... ON DUPLICATE KEY UPDATE的实践
转: Mysql中INSERT ... ON DUPLICATE KEY UPDATE的实践 阿里加多 0.1 2018.03.23 17:19* 字数 492 阅读 2613评论 2喜欢 1 一.前 ...
- python 字典的定义以及方法
7.字典的转换: dict(x=1,y=2) ==> {'y': 2, 'x': 1} dict([(i,element) for i, element in enumerate(['one ...
- 面向对象【day07】:知识点回顾(十一)
本节内容 1.self关键字 2.封装 3.继承 4.静态方法 一.self关键字 作用:调用当前方法的对象 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class Foo: ...
- idea中加入tomcat
File—>Setting—>Build,Execution,Deployment—->Application Servers—>”+”这里添加了之后Edit Configur ...
- java读大文件最快性能【转】
java读大文件最快性能 完全引用自: 几种读大文件方法的效率对比测试 据说1.88g只要5秒左右,未亲测. /** * 读大文件 * BufferedReader + char[] * @throw ...
- Part-Six
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12.