js 时间转换
//时间转换成时间戳
function DateToUnix(string) {
var f = string.split(' ', 2);
var d = (f[0] ? f[0] : '').split('-', 3);
var t = (f[1] ? f[1] : '').split(':', 3);
var time = (new Date(
parseInt(d[0], 10) || null,
(parseInt(d[1], 10) || 1) - 1,
parseInt(d[2], 10) || null,
parseInt(t[0], 10) || null,
parseInt(t[1], 10) || null,
parseInt(t[2], 10) || null
)).getTime() / 1000
return time;
}
//GMT时间格式转换成字符串
function GMTToStr(time) {
let date = new Date(time)
let Str = date.getFullYear() + '-' +
(date.getMonth() + 1) + '-' +
date.getDate() + ' ' +
date.getHours() + ':' +
date.getMinutes() + ':' +
date.getSeconds()
return Str
}
//时间转换成GMT格式
function parserDate(date) {
var t = Date.parse(date);
if(!isNaN(t)) {
return new Date(Date.parse(date.replace(/-/g, "/")));
} else {
return new Date();
}
};
最新文章
- 关于配置Spring框架的多个propertyConfigurer的问题
- The Skins of the Substance
- js图片放大镜
- RHEL5.8使用yum安装X Window System
- 李洪强 - C语言8-Scanf函数
- Jquery使用ajax以及angularjs 动态模板加载并进行渲染
- Flask框架学习笔记(API接口管理平台 V2.0)
- 多控制器之UIApplication
- 理解CSS中的三种选择器>;+~
- 一点BPXA的思考
- iOS状态栏颜色
- Sqoop是一款开源的工具,主要用于在HADOOP(Hive)与传统的数据库(mysql、oracle...)间进行数据的传递
- Vertica对于所计算的时间SQL声明大全
- React-Native 之 Modal介绍与使用
- Django web框架-----Django templates模板
- USM-V1.0
- 介绍HTTP协议的传输过程
- 码云 使用 汉化 GitHub
- python Django 项目创建
- 安装好kali要做的事
热门文章
- [Javascript] Deep Search nested tag element in DOM tree
- libyuv库的使用
- 解决MyEclipse开启后总是不停的在Update index
- HDU1846(巴什博奕)
- 求int型数据在内存中存储时1的个数
- xcode Automatic signing is unable to resolve an issue with the ";ShowCar-IOS"; target's entitlements
- Vue.js和Nodejs的关系
- Python 3.x 判断 dict 是否包含某个键
- BZOJ 4742 DP
- 134. Gas Station leetcode