Ext.util.Format.date 时间格式的设置与转换
Ext.util.Format.date
- var d = new Date(value.time);
- var s = Ext.util.Format.date(d, 'Y-m-d H:m:s');
- return s;
在Chrome的Develop Tools中断点调试,发现这些变量的值为:
value.time: 1396257528000
d: Mon Mar 31 2014 17:18:48 GMT+0800 (中国标准时间)
s: "2014-03-31 17:03:48"
年月日时分秒中,只有分钟不对,硬生生的差了15分钟,汗!
单步跟踪进去,发现是Extjs的源码(VM13060)里有问题,竟然用月份代替了分钟:
- (function() {
- var Ext = window.ExtBox1;
- return Ext.String.leftPad(this.getFullYear(), 4, '0') + '-' + Ext.String.leftPad(this.getMonth() + 1, 2, '0') + '-'
- + Ext.String.leftPad(this.getDate(), 2, '0') + ' ' + Ext.String.leftPad(this.getHours(), 2, '0') + ':'
- + Ext.String.leftPad(this.getMonth() + 1, 2, '0') + ':' + Ext.String.leftPad(this.getSeconds(), 2, '0')
- })
仔细一想,发现是分钟(minute)与月份(month)搞错了,分钟应该用i而不是m
- Ext.util.Format.date(d, 'Y-m-d H:i:s');
Extjs的源码里有各种格式的功能的:
- formatCodes : {
- d: "Ext.String.leftPad(this.getDate(), 2, '0')",
- D: "Ext.Date.getShortDayName(this.getDay())",
- j: "this.getDate()",
- l: "Ext.Date.dayNames[this.getDay()]",
- N: "(this.getDay() ? this.getDay() : 7)",
- S: "Ext.Date.getSuffix(this)",
- w: "this.getDay()",
- z: "Ext.Date.getDayOfYear(this)",
- W: "Ext.String.leftPad(Ext.Date.getWeekOfYear(this), 2, '0')",
- F: "Ext.Date.monthNames[this.getMonth()]",
- m: "Ext.String.leftPad(this.getMonth() + 1, 2, '0')",
- M: "Ext.Date.getShortMonthName(this.getMonth())",
- n: "(this.getMonth() + 1)",
- t: "Ext.Date.getDaysInMonth(this)",
- L: "(Ext.Date.isLeapYear(this) ? 1 : 0)",
- o: "(this.getFullYear() + (Ext.Date.getWeekOfYear(this) == 1 && this.getMonth() > 0 ? +1 : "
- "(Ext.Date.getWeekOfYear(this) >= 52 && this.getMonth() < 11 ? -1 : 0)))",
- Y: "Ext.String.leftPad(this.getFullYear(), 4, '0')",
- y: "('' + this.getFullYear()).substring(2, 4)",
- a: "(this.getHours() < 12 ? 'am' : 'pm')",
- A: "(this.getHours() < 12 ? 'AM' : 'PM')",
- g: "((this.getHours() % 12) ? this.getHours() % 12 : 12)",
- G: "this.getHours()",
- h: "Ext.String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0')",
- H: "Ext.String.leftPad(this.getHours(), 2, '0')",
- i: "Ext.String.leftPad(this.getMinutes(), 2, '0')",
- s: "Ext.String.leftPad(this.getSeconds(), 2, '0')",
- u: "Ext.String.leftPad(this.getMilliseconds(), 3, '0')",
- O: "Ext.Date.getGMTOffset(this)",
- P: "Ext.Date.getGMTOffset(this, true)",
- T: "Ext.Date.getTimezone(this)",
- Z: "(this.getTimezoneOffset() * -60)",
- c: function() {
- for (var c = "Y-m-dTH:i:sP", code = [], i = 0, l = c.length; i < l; ++i) {
- var e = c.charAt(i);
- code.push(e == "T" ? "'T'" : utilDate.getFormatCode(e));
- }
- return code.join(" + ");
- },
- U: "Math.round(this.getTime() / 1000)"
- },
原文链接:https://blog.csdn.net/gaojinshan/article/details/22683777
Ext.util.Format.date 时间格式的设置与转换的更多相关文章
- Ext.util.Format.date与Ext.Date.format区别, 转换时间戳
在Extjs中装时间戳使用如下两种都可以: Ext.util.Format.date(time,'U'); Ext.Date.format(time, 'U'); 为了找到它们的区别,查看源代码,以E ...
- ExtJs之Ext.util.Format
<!DOCTYPE html> <html> <head> <title>ExtJs</title> <meta http-equiv ...
- Extjs4 中date时间格式的问题
在Grid中显示时间,后台传过来的是date格式的数据(PHP date('Y-m-d', time()),一般在Ext model中定义数据的类型和格式: {name:'birth', type:' ...
- 按照相应的格式获取系统时间并将其转化为SQL中匹配的(date)时间格式
在获取时间时需要对时间格式进行设置,此时就需要用到SimpleDateFormat 类 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM ...
- Date时间格式的转换以及一些用法
import java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.u ...
- jmeter中对于各类时间格式的设置
最普通的设置为使用 函数助手中的__time, 设置好需要使用的类型,并设置接收参数即可 YMD = yyyyMMdd HMS = HHmmss YMDHMS = yyyyMMdd-HHmmss 第二 ...
- WordPress 博客文章时间格式the_time()设置
国外设计的WordPress 主题里的文章的时间格式是类似“十一月 21, 2010”这种格式的,而中国人习惯的是年在前,月紧跟其后,日在末尾,所以看国外的就显得很别扭,但是我们可以通过修改WP时间代 ...
- new Date时间格式转换方法
平时经常会使用到时间转换,组件库已经有很多组件可以自动生成时间类型了,但是底层的封装方法还是得有 获取当前时间 new Date() 或者自己拥有一个毫秒时间 方法如下 /** * title: 时 ...
- 关于javascript中时间格式和时间戳的转换
当前时间获取的各种函数: var myDate = new Date();myDate.getYear(); //获取当前年份(2位),已经不推荐使用myDate.getFullYear ...
随机推荐
- js弹出层学习
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- Java之扫描目录,修改文件内容
扫描目录下文件,修改文件中指定内容 package org.utils.tools.fileoper; import java.io.*; import java.util.ArrayList; im ...
- js new关键字
实现new 关键字只需4步 1. 声明一个对象: 2. 把这个对象的__proto__ 指向构造函数的 prototype; 3. 以构造函数为上下文执行这个对象: 4. 返回这个对象. 简洁的代码示 ...
- Duplicate spring bean id
问题背景:从本地调用服务器的dubbo接口进行测试 实现思路:基于IDEA+Spring+maven+Dubbo搭建测试项目,从本地直接调用 具体实现思路可参考博客:https://www.cnb ...
- 小菜菜mysql练习解读分析2——查询存在" 01 "课程但可能不存在" 02 "课程的情况(不存在时显示为 null )
“查询存在" 01 "课程但可能不存在" 02 "课程的情况(不存在时显示为 null )” ——翻译为:课程表里面,存在01的信息,未必满足有02的课程情况 ...
- Codeforces Round #530 Div. 1 自闭记
A:显然应该让未确定的大小尽量大.不知道写了啥就wa了一发. #include<iostream> #include<cstdio> #include<cmath> ...
- Triangle Counting UVA - 11401(递推)
大白书讲的很好.. #include <iostream> #include <cstring> using namespace std; typedef long long ...
- 前端学习 -- Html&Css -- 相对定位 绝对定位 固定定位
相对定位 - 定位指的就是将指定的元素摆放到页面的任意位置,通过定位可以任意的摆放元素. - 通过position属性来设置元素的定位. -可选值: static:默认值,元素没有开启定位: rela ...
- JDK自带线程池介绍及使用环境
1.newFixedThreadPool创建一个指定工作线程数量的线程池.每当提交一个任务就创建一个工作线程,如果工作线程数量达到线程池初始的最大数,则将提交的任务存入到池队列中. 2.newCach ...
- 21天实战caffe笔记_第三天
1 深度学习工具汇总 (1) caffe : 由BVLC开发的基于C++/CUDA/Python实现的卷积神经网络,提供了面向命令行.Matlab和Python的绑定接口.特性如下: A 实现了前馈 ...