js时间格式化
来源:互联网 发布:通俗理解互补滤波算法 编辑:程序博客网 时间:2024/06/03 20:04
解决苹果时间乱码问题,主流浏览器都正常显示时间
// 格式化日期时间
function geshiTime(value) {var date2 = value;
var arrTime = date2.split("T");
var year = arrTime[0].replace("-", "/").replace("-", "/");
var time = arrTime[1].split(":");
var data = year + " " + (parseInt(time[0]) + 8) + ":" + time[1];
var dataAllTime = new Date(year);
return timeChange(year, time);
};
function timeChange(year, time) {
var dataString = "";
var Hours = parseInt(time[0]);
var Minutes = parseInt(time[1]);
var data = year;
if (Minutes < 10) {
Minutes = "0" + Minutes;
}
if (Hours >= 16) {
dataString = addDate(data) + " " + (Hours + 8 - 24) + ":" + Minutes;
} else {
dataString = data.replace("/", "-").replace("/", "-") + " "
+ (Hours + 8) + ":" + Minutes;
}
return dataString;
}
function addDate(date, days) {
if (days == undefined || days == '') {
days = 1;
}
var date = new Date(date);
date.setDate(date.getDate() + days);
var month = date.getMonth() + 1;
var day = date.getDate();
return date.getFullYear() + '-' + getFormatDate(month) + '-'
+ getFormatDate(day);
}
// 日期月份/天的显示,如果是1位数,则在前面加上'0'
function getFormatDate(arg) {
if (arg == undefined || arg == '') {
return '';
}
var re = arg + '';
if (re.length < 2) {
re = '0' + re;
}
return re;
}
// 格式化日期
function geshidate(value) {
/*
* var date = new Date(value); var datetime = date.getFullYear() + "-"// "年" +
* ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0" +
* (date.getMonth() + 1)) + "-"// "月" + (date.getDate() < 10 ? "0" +
* date.getDate() : date.getDate()) + " ";
*/
var date2 = value;
var arrTime = date2.split("T");
return arrTime[0];
};
0 0
- 【js】js时间格式化
- js中格式化时间
- js时间日期格式化
- js 格式化时间
- js 格式化时间函数
- js格式化时间
- js 格式化时间
- js时间格式化
- js中格式化时间
- js 格式化时间
- js的时间格式化
- js 时间格式化
- js格式化时间
- js时间格式化
- js字符串格式化时间
- js 时间格式化
- 用js格式化时间
- js 时间格式化
- Ubuntu16.04不能挂载windows的分区
- 毕业设计ArcGIS相关操作
- Unity3D游戏开发之Lua与游戏的不解之缘(4)
- Android 常用命令
- 替换指定文件夹图片,并保留原来尺寸
- js时间格式化
- Leetcode 11. Container With Most Water
- 读《丰田精益管理 采购与供应商管理》
- 项目管理切忌目中无人
- COM多线程原理和应用
- C++ sleep and wait
- gdufe acm 1178 拼接数字
- thinkphp输出与调用view页面呈现
- JAVA多线程不安全问题解决方案(多线程并发同一资源)。