js 时间格式与时间戳的相互转换
来源:互联网 发布:ios蜂窝移动数据开关 编辑:程序博客网 时间:2024/05/29 19:38
一.时间转换时间戳
function transdate(endTime){
var date=new Date();
date.setFullYear(endTime.substring(0,4));
date.setMonth(endTime.substring(5,7)-1);
date.setDate(endTime.substring(8,10));
date.setHours(endTime.substring(11,13));
date.setMinutes(endTime.substring(14,16));
date.setSeconds(endTime.substring(17,19));
return Date.parse(date)/1000;
}
二.时间戳转换时间
(1):转换成 2011-3-16 16:50:43 格式:
function getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ")
return tt;
}
(2):转换成 2011年3月16日 16:50:43:
function getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString()
return tt;
}
(3):转换成 2011年3月16日 16:50
function getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString().substr(0,16);
return tt;
}
function transdate(endTime){
var date=new Date();
date.setFullYear(endTime.substring(0,4));
date.setMonth(endTime.substring(5,7)-1);
date.setDate(endTime.substring(8,10));
date.setHours(endTime.substring(11,13));
date.setMinutes(endTime.substring(14,16));
date.setSeconds(endTime.substring(17,19));
return Date.parse(date)/1000;
}
二.时间戳转换时间
(1):转换成 2011-3-16 16:50:43 格式:
function getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ")
return tt;
}
(2):转换成 2011年3月16日 16:50:43:
function getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString()
return tt;
}
(3):转换成 2011年3月16日 16:50
function getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString().substr(0,16);
return tt;
}
0 0
- js 时间格式与时间戳的相互转换
- js时间戳与日期格式之间的相互转换
- 时间戳与时间格式的相互转换
- js 时间格式与时间戳的相互转换示例代码
- js 时间格式与时间戳的相互转换示例代码
- mysql 时间戳与日期格式的相互转换
- mysql 时间戳与日期格式的相互转换
- mysql 时间戳与日期格式的相互转换
- mysql 时间戳与日期格式的相互转换
- mysql 时间戳与日期格式的相互转换
- 时间戳与时间的相互转换
- 时间与时间戳的相互转换
- 时间与时间戳的相互转换
- php与js时间戳相互转换
- JS日期时间与时间戳相互转换
- js时间戳与时间日期间相互转换
- js,jQuery时间与时间戳相互转换
- js时间戳的相互转换
- 排序
- android ADB命令的使用
- 用单例模式写一个php数据库管理类
- java设计模式学习笔记-原型模式
- 爆炸声刚落埃及宣布穆兄会为恐怖组织
- js 时间格式与时间戳的相互转换
- Email营销课堂:邮件群发平台与软件区别
- 破解windows7登陆密码
- java对象序列化与反序列化
- 第一次搭VPN Server
- 模拟器上没有Home键
- 一个经典例子让你彻彻底底理解java回调机制
- 使用ZFTool创建全新的zend framework 2项目
- Ubuntu Server 12.04 配置防火墙iptables