格式化日期(月和星期)
Posted 2350305682
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了格式化日期(月和星期)相关的知识,希望对你有一定的参考价值。
// /**
// * 格式化日期(月和星期)
// * sFormat:日期的格式(如yy-MM-dd)。年:y,月:M,日:d,时:h,分:m,秒:s
// * sLanguage: 默认为中文。当为‘en‘的时候是英文。
// */
// window.dateFormat=function(date, sFormat, sLanguage){
// var time = {};
// time.Year = date.getFullYear();
// time.TYear = ("" + time.Year).substr(2);
// time.Month = date.getMonth() + 1;
// time.TMonth = time.Month < 10 ? "0" + time.Month : time.Month;
// time.Day = date.getDate();
// time.TDay = time.Day < 10 ? "0" + time.Day : time.Day;
// time.Hour = date.getHours();
// time.THour = time.Hour < 10 ? "0" + time.Hour : time.Hour;
// time.hour = time.Hour < 13 ? time.Hour : time.Hour;
// time.Thour = time.hour < 10 ? "0" + time.hour : time.hour;
// time.Minute = date.getMinutes();
// time.TMinute = time.Minute < 10 ? "0" + time.Minute : time.Minute;
// time.Second = date.getSeconds();
// time.TSecond = time.Second < 10 ? "0" + time.Second : time.Second;
// time.Millisecond = date.getMilliseconds();
// time.Week = date.getDay();
//
// var MMMArrEn = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
// MMMArr = ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
// WeekArrEn = ["Sun", "Mon", "Tue", "Web", "Thu", "Fri", "Sat"],
// WeekArr = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
// oNumber = time.Millisecond / 1000;
//
// if (sFormat != undefined && sFormat.replace(/\s/g, "").length > 0) {
// if (sLanguage != undefined && sLanguage === "en") {
// MMMArr = MMMArrEn.slice(0);
// WeekArr = WeekArrEn.slice(0);
// }
// sFormat = sFormat.replace(/yyyy/ig, time.Year)
// .replace(/yyy/ig, time.Year)
// .replace(/yy/ig, time.TYear)
// .replace(/y/ig, time.TYear)
// .replace(/MMM/g, MMMArr[time.Month - 1])
// .replace(/MM/g, time.TMonth)
// .replace(/M/g, time.Month)
// .replace(/dd/ig, time.TDay)
// .replace(/d/ig, time.Day)
// .replace(/HH/g, time.THour)
// .replace(/H/g, time.Hour)
// .replace(/hh/g, time.Thour)
// .replace(/h/g, time.hour)
// .replace(/mm/g, time.TMinute)
// .replace(/m/g, time.Minute)
// .replace(/ss/ig, time.TSecond)
// .replace(/s/ig, time.Second)
// .replace(/fff/ig, time.Millisecond)
// .replace(/ff/ig, oNumber.toFixed(2) * 100)
// .replace(/f/ig, oNumber.toFixed(1) * 10)
// .replace(/EEE/g, WeekArr[time.Week]);
// }else {
// sFormat = time.Year + "-" + time.Month + "-" + time.Day + " " + time.Thour + ":" + time.TMinute + ":" + time.TSecond;
// }
// return sFormat;
// };
以上是关于格式化日期(月和星期)的主要内容,如果未能解决你的问题,请参考以下文章
java 给月份3月和该月1日是星期二,求该月最后一个工作日的日期 如何实现