js时间格式转换

格式化时间转成时间戳

//格式化转时间戳(单位秒)
function strtotime(strtime) {
strtime = strtime.substring(0, 19);
strtime = strtime.replace(/-/g, '/');
strtime = new Date(strtime).getTime() / 1000;
return strtime;
}

时间戳转格式化时间

        //时间戳(单位秒)转格式化
function getMyDate(str) {
str = str * 1000;
var oDate = new Date(str),
oYear = oDate.getFullYear(),
oMonth = oDate.getMonth() + 1,
oDay = oDate.getDate(),
oHour = oDate.getHours(),
oMin = oDate.getMinutes(),
oSen = oDate.getSeconds(),
oTime = oYear + '-' + getzf(oMonth) + '-' + getzf(oDay) + ' ' + getzf(oHour) + ':' +
getzf(oMin) + ':00'; //最后拼接时间
return oTime;
};

js 时间格式转换的更多相关文章

  1. moment.js 时间格式转换

    moment.js 时间格式转换 moment.js 时间转化 bug 格式错误 bug 02:00 => 14:00 format HH 与 hh HH === 24 小时制 hh === 1 ...

  2. js时间格式转换的几种方法

    公司项目需要获取时间并且转换格式,之前没有实现过但读过源码,新来的小哥给我讲了下细节.算是学到了..... function getLocalTime(){ var now=new Date(); v ...

  3. js时间格式转换

    在javascript中直接输出Date得到的结果是这样的: function date(){ var date = new Date(); alert(date); } 结果是:Mon Jun 15 ...

  4. 10. js时间格式转换

    {   field : 'CREATE_TIME',   width : fixWidth(0.10),   title : '创建时间',   align : 'center',   hidden: ...

  5. js时间格式转换,传入时间戳,第二哥参数是格式,也可不传

    export function parseTime(time, pattern) { if (arguments.length === 0 || !time) { return null } cons ...

  6. JS时间格式 GMT格式转换

    JavaScript时间格式转换总结 1.当前系统区域设置格式(toLocaleDateString和toLocaleTimeString) 例子:(new Date()).toLocaleDateS ...

  7. JS 时间格式CST转GMT

    近几天,在做百度地图时,需要转换时间格式并做显示,但是发现显示的时间格式,出现了错乱,二者的日期和小时都出现了变动.例如: 原始时间格式:Thu Aug 18 20:38:54 CST 2016 转换 ...

  8. C# MVC 用户登录状态判断 【C#】list 去重(转载) js 日期格式转换(转载) C#日期转换(转载) Nullable<System.DateTime>日期格式转换 (转载) Asp.Net MVC中Action跳转(转载)

    C# MVC 用户登录状态判断   来源:https://www.cnblogs.com/cherryzhou/p/4978342.html 在Filters文件夹下添加一个类Authenticati ...

  9. JS时间格式CST转GMT

    转换方法:JS 时间格式CST转GMT 时区和Date:Java中的Date和时区转换

随机推荐

  1. 用赋值表达式作为bool值

    enum Status { stOk, stQuit, stError }; int main() { Status status; int n; bool b1 = (status = stOk); ...

  2. 都闪开,不用任何游戏引擎,html也能开发格斗游戏

    html格斗游戏,对打游戏 不用引擎,不用画布canvas,不用任何库(包括jquery), 原生div+img组件,开发格斗游戏游戏教程视频已经上传 b站:https://www.bilibili. ...

  3. NR / 5G - The Round Robin algorithm

  4. mysql 支持emoji表情

    在mysql插入emoji表情,出现错误: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x8A' for column ' ...

  5. OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol

    gitlab版本为社区版: gitlab-ce_11.5.4-ce.0_amd64.deb 目录:/var/cache/apt/archives 配置邮箱的主要参数: user['git_user_e ...

  6. LVS 部署

    一.LVS的组成 LVS 由2部分程序组成,包括 ipvs 和 ipvsadm. 1. ipvs(ip virtual server):一段代码工作在内核空间,叫ipvs,是真正生效实现调度的代码.2 ...

  7. shell脚本 inotify + rsync 同步脚本

    1.这是很简单的一个 文件监控+触发同步脚本 监控一台服务器下的一个文件夹,发生改变则向另一个个文件夹进行同步. 具体的inotify命令  rsync命令  可以看linux分类下的介绍 inoti ...

  8. Kvm 简介 安装 使用 桥接网络

    KVM 全称是 基于内核的虚拟机(Kernel-based Virtual Machine),它是一个 Linux 的一个内核模块,该内核模块使得 Linux 变成了一个 Hypervisor: 它由 ...

  9. phpmyadmin配置文件详解

    PHPMyadmin配置文件config.inc.php或config.default.php内容及作用解析大致如下: /** * phpMyAdmin Configuration File * * ...

  10. implements Serializable有什么作用?

    没有implements Serializable,你就不能通过rmi(包括ejb)提供远程调用.serialization 允许你将实现了Serializable接口的对象转换为字节序列,这些字节序 ...