php/js将 CST时间转成格式化时间
PHP :比较简单
$str = 'Wed Jul 24 11:24:33 CST 2019';
echo date('Y-m-d H:i:s', strtotime($str));
echo date('Y-m-d H:i:s',strtotime("$date1 -14 hours"));
PHP 直接格式化的时间相差14个小时,然后我又减去了14个小时,

JavaScript:好复杂的感觉
dateFormat = function (date, format) {
date = new Date(date);
var o = {
'M+' : date.getMonth() + , //month
'd+' : date.getDate(), //day
'H+' : date.getHours(), //hour
'm+' : date.getMinutes(), //minute
's+' : date.getSeconds(), //second
'q+' : Math.floor((date.getMonth() + ) / ), //quarter
'S' : date.getMilliseconds() //millisecond
};
if (/(y+)/.test(format))
format = format.replace(RegExp.$, (date.getFullYear() + '').substr( - RegExp.$.length));
for (var k in o)
if (new RegExp('(' + k + ')').test(format))
format = format.replace(RegExp.$, RegExp.$.length == ? o[k] : ('' + o[k]).substr(('' + o[k]).length));
return format;
}
var _xbdate = new Date(dateFormat('Wed Jul 24 11:24:33 CST 2019','yyyy-MM-dd HH:mm:ss')); //将CST时间转换为GMT格式
console.log(_xbdate); nowDate = new Date(_xbdate.valueOf() - * * *);// 当前时间减去14小时 console.log(nowDate);
var year = nowDate.getFullYear();
var month = nowDate.getMonth() + < ? "" + (nowDate.getMonth() + ): nowDate.getMonth() + ;
var day = nowDate.getDate() < ? "" + nowDate.getDate() : nowDate.getDate();
var hours = nowDate.getHours()<?"" + nowDate.getHours():nowDate.getHours();
var minutes = nowDate.getMinutes()<?"" + nowDate.getMinutes():nowDate.getMinutes();
var seconds = nowDate.getSeconds()<?"" + nowDate.getSeconds():nowDate.getSeconds(); var dateStr = year + "-" + month + "-" + day+ " " + hours+ ":" + minutes+ ":" + seconds; //转为YY-mm-dd H:i:s
console.log(dateStr);
运行结果

真麻烦啊,PHP是世界上最好的语言!!!
但是js确实强大啊
小科普:中央标准时间(CST)
CST可视为美国、澳大利亚、古巴或中国的标准时间。
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
php/js将 CST时间转成格式化时间的更多相关文章
- 用js将毫秒时间转成正常时间
1. 将毫秒时间转成正常时间 //#region 将毫秒转换成正常的日期 function getDate(time) { var date = new Date(parseInt(time)); v ...
- 将本地时间转换成 UTC 时间,0时区时间
// 将时间戳转换成日期格式: function timestampToTime(timestamp) { var date = new Date(timestamp);//时间戳为10位需*1000 ...
- Python获取当前时间_获取格式化时间_格式化日期
Python获取当前时间_获取格式化时间: Python获取当前时间: 使用 time.time( ) 获取到距离1970年1月1日的秒数(浮点数),然后传递给 localtime 获取当前时间 #使 ...
- python中将HTTP头部中的GMT时间转换成datetime时间格式
原文: https://blog.csdn.net/zoulonglong/article/details/80585716 需求背景:目前在做接口的自动化测试平台,由于接口用例执行后返回的结果中的时 ...
- java时间工具类型,格式化时间,最近7天 月初 月末 季度 月度 时间格式化 等等
package com.tz.util; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util. ...
- 调用get_str_time(时间), 就能把毫秒的时间转换成格式化的 ,转化时间戳的方法
function get_str_time(time){ var datetime = new Date(); datetime.setTime(time); var year = datetime. ...
- PHP excel reader , excel时间转成php时间格式
最近,在做一个导入功能,在系统中使用PHPExcel类库,读取上传的Excel文件,然后进行字段映射,最后将Excel内的数据导入到系统中.其中,关于日期格式的导入,使我犯了难. 首先,如何导入日期, ...
- EL 标准格式时间 转换成 常用时间yyyy-MM-dd
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%><fmt:format ...
- utc时间转成local时间
public static Date utcToLocal(String utcTime){ SimpleDateFormat sdf = new SimpleDateFormat("yyy ...
随机推荐
- win10修改jupyter notebook默认路径
安装anaconda3 ,因此自带jupyter notebook 发送到jupyter notebook到桌面快捷方式 右击属性,将目标的%USERPROFILE%,修该为自己需要的路径 起始位置修 ...
- Android_SQLite简单的增删改查
SQLite数据库,和其他的SQL数据库不同, 我们并不需要在手机上另外安装一个数据库软件,Android系统已经集成了这个数据库,我们无需像 使用其他数据库软件(Oracle,MSSQL,MySql ...
- SQL Server database – Error 3743
Database mirroring must be removed before you drop SQL Server database – Error 3743 If you try to dr ...
- php函数的巧妙应用
直接切入正题: 1.extract();函数从数组中把变量导入到当前的符号表中 对于数组中的每个元素,键名用于变量名,键值用于变量值. 第二个参数 type 用于指定当某个变量已经存在,而数组中又有同 ...
- elasticsearch 5.5 query 过程 源码分析
(1)请求 transfer to 任意node 节点 标记为coordinate node server入口函数 transportSearchAction doExecute方法 coordin ...
- 树莓派环境下使用python将h264格式的视频转为mp4
个人博客 地址:https://www.wenhaofan.com/a/20190430144809 下载安装MP4Box 命令行下执行以下指令安装MP4Box sudo apt-get inst ...
- python3练习100题——039
原题链接:http://www.runoob.com/python/python-exercise-example39.html 题目:有一个已经排好序的数组.现输入一个数,要求按原来的规律将它插入数 ...
- ECMAScript基本语法——⑤运算符 void
void阻止返回值的运算符,没有返回值
- Max Sum Plus Plus HDU - 1024 基础dp 二维变一维的过程,有点难想
/* dp[i][j]=max(dp[i][j-1]+a[j],max(dp[i-1][k])+a[j]) (0<k<j) dp[i][j-1]+a[j]表示的是前j-1分成i组,第j个必 ...
- c++中sort基础用法
用法一:数组排序 对一个数组进行升序排序 #include <algorithm> #include <iostream> #include <cstdio> us ...