CST可以为如下4个不同的时区的缩写:
  美国中部时间:Central Standard Time (USA) UT-6:00
  澳大利亚中部时间:Central Standard Time (Australia) UT+9:30
  中国标准时间:China Standard Time UT+8:00
  古巴标准时间:Cuba Standard Time UT-4:00
GMT 世界时UT [1]  即格林尼治 [1]  平太阳时间,是指格林尼治所在地的标准时间,也是表示地球自转速率的一种形式
GMT指的是格林威治中央区时,北京位于东八区,也就是北京的地方时比中央时区的地方时早8小时。GMT-4:00表示比中央区时晚小时,也就是说这个地方在中央时区以西,西四区
 
原始时间格式:Thu Aug 18 20:38:54 CST 2016
GMT时间格式:Thu Aug 18 2016 20:38:54 GMT+0800 (中国标准时间)
 转换时间格式:2016-08-18 20:38:54
js 中运用,我是要将一个foreach中的时间转化,所以我是在foreach中调用了js中的转化函数,注意要将js的转化函数放在调用之前,否则就可能找不到!!!
还有一个注意点,调用的时候要函数时,要用双引号,传过去的是字符串!!!!
 
<script type="text/javascript">
function dateToGMT(strDate) {
if(null==strDate || ""==strDate){
return "";
}
var dateStr=strDate.trim().split(" ");
var strGMT = dateStr[0]+" "+dateStr[1]+" "+dateStr[2]+" "+dateStr[5]+" "+dateStr[3]+" GMT+0800";
var date = new Date(Date.parse(strGMT));
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();
var minute = date.getMinutes();
minute = minute < 10 ? ('0' + minute) : minute;
var second = date.getSeconds();
second = second < 10 ? ('0' + second) : second; return y+"-"+m+"-"+d+" "+h+":"+minute+":"+second;
}
function time(id, strDate){
document.getElementById(id).innerHTML = dateToGMT(strDate);
}
</script>

 

               <c:set var = "i" value = "0"/>
<c:forEach items="${requestScope.sppurchases}" var="spp"
varStatus="stat">
<tr class="cart_item">
<td class="product-price"><span class="amount">${spp.dingdanid}</span></td> <td class="product-name"><a href="${pwd }/goods/detial?id=${spp.gid}">${requestScope.name[i]}</a></td> <td class="product-price"><span class="amount">${spp.num}</span></td> <td class="product-price"><span class="amount">${spp.money}</span></td> <td class="product-price"><span class="amount" id = ${spp.id } >${spp.purtime}
<script type="text/javascript">time( "${spp.id }" , "${spp.purtime}")</script>
</span></td>
</tr>
<c:set var = "i" value = "${i + 1}"/>
</c:forEach>

  

 

29-jsp中用js进行时间格式转化的更多相关文章

  1. Sql server 时间格式转化

    --.SQL时间格式转化 --日期转换参数 ) --2009-03-15 15:10:02 ),'-',''),' ',''),':','') ) , ) --2009/03/15 ) , ) ) , ...

  2. js判断时间格式是否有效

    js判断时间格式是否有效 1 短时间,形如 (13:04:06)function isTime(str){var a = str.match(/^(\d{1,2})(:)?(\d{1,2})\2(\d ...

  3. 原生JS日历 + JS格式化时间格式

    公司项目中用到,以前没做过,废了好几个小时 终于做好了 先来效果图(暂时没写样式 凑合着看吧) 点击左右按钮都能改变月份 下方表格中的数据也会跟着变化 贴上代码 : html部分: <div s ...

  4. JS 格林威治时间格式(GMT)格式化

    Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, //month & ...

  5. 21-js 实现评论时间格式转化

    js里面要用可以用伊尔表达式,循环是用js: document.getElementById("${pj.pltime }").innerHTML = dateToGMT(&quo ...

  6. oracle 时间格式转化以及计算

    --A表中的日期字段 create_date   例如:2017-08-05  转化为2017年8月5日   oracle 在这里的双引号会忽略 select to_char(to_date(tt.c ...

  7. JS表格显示时间格式

    <!-- JS代码区 --> <script type='text/javascript'> $(function() { var grid_selector23 = &quo ...

  8. 时间格式转化 String2datestyle

    时间格式转化成string工具类: package cn.javass.util; import java.text.DateFormat; import java.text.SimpleDateFo ...

  9. win7 蛋疼的时间格式转化

    win7系统 获得系统时间为 2015年1月1日 星期5 10:10 数据库中时间格式 是不认识的 转化为 DateTime.Now.ToString("yyyy-MM-dd HH:mm:s ...

随机推荐

  1. js 选项卡制作

    知识回顾,制作JS选项卡,仅供参考 html代码: <!DOCTYPE html> <html lang="en"> <head> <me ...

  2. Win7下npm命令Error: ENOENT问题解决

    Win7下在执行npm命令,比如npm list时出现下面错误:

  3. Mastering Creativity:A brief guide on how to overcome creative blocks

    MASTERING CREATIVITY, 1st EditionThis guide is free and you are welcome to share it withothers.From ...

  4. How to Pronounce the Months of the Year

    How to Pronounce the Months of the Year Share Tweet Share Tagged With: Most Popular Some of the mont ...

  5. 正则表达式(Python)

    课题 使用正则表达式匹配字符串 使用正则表达式 "\d{3}-(\d{4})-\d{2}" 匹配字符串 "123-4567-89" 返回匹配结果:'" ...

  6. Android DevArt4:IntentFilter学习及深入~问题描述:在不指定具体action前提下,如果有两个以上的Activity,具有完全相同的intent-filter,项目同步是否会出现异常?程序运行是否会崩溃?

    概述:GitHub IntentFilter意图过滤器,三种匹配规则:action.category.data 重点:过滤规则中必须设置 '<category android:name=&quo ...

  7. springboot 异步执行程序

    一步:在启动项里面加入注解    (类似定时) //开启异步调用方法@EnableAsync 二步:在包中的AsyncTask .java 类中 写三个方法 三步:是在DoTask.java 中调用的 ...

  8. python在DWR框架下的post

    使用requests.post,但一直要在headers中设置相应的Content-Type和Referer # coding=utf-8 import urllib2 import requests ...

  9. 使用__all__限制模块可被导入对象

    经常我们会编写自定义模块,用于被别的脚本调用;有时候为了方便,会使用from module_name import *的方式导入,这样会把模块中全部对象导入进来; 使用__all__结合列表,可以控制 ...

  10. CSS 盒子大小

    盒子的宽和高 盒子的大小通过宽和高来指定. 默认情况下,盒子的大小刚好容纳其中的内容. 两个属性设置盒子的宽和高 width 设置宽 height 设置高 示例: 1 2 3 4 5 6 7 8 9 ...