var getCurrentWeek = function (day) { var days = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]; //定义数组 var week = []; //获取当前星期X(0-6,0代表星期天) var index = new Date(day).getDay(); //循环 for (va…
发现网上用js获取某月最后一个的方式大多比较复杂,上个简单的: new Date(2013,4).toJSON().substring(0,10) new Date(2013,4,0).toLocaleFormat('%Y-%m-%d') 显示"2013-04-30". year+'-'+month+'-'+new Date(year,month,0).getDate();//获取当月最后一天日期 OK. 另外,前两种方法貌似IE上兼容性有问题,自己看着用吧…
var myDate = new Date();myDate.getYear(); //获取当前年份(2位)myDate.getFullYear(); //获取完整的年份(4位,1970-????)myDate.getMonth(); //获取当前月份(0-11,0代表1月)myDate.getDate(); //获取当前日(1-31)myDate.getDay(); //获取当前星期X(0-6,0代表星期天)myDate.getTi…
<html xmlns="http://www.w3.org/1999/xhtml" > <meta charset="UTF-8"> <head> <title>获取当年当月最后一天日期</title> <script language="javascript"> function getLastDay(){ var year = document.getElementBy…
1.获取某月第一天和最后一天日期 function getDateByMonth (timeStamp) { let inDate = new Date(timeStamp) let year = inDate.getFullYear() let month = inDate.getMonth() let startTime = new Date(year, month, 1).getTime() let endTime = new Date(year, month + 1, 0).getTim…
效果: 代码: //用于获取日期本周.本月.本季度的js //Author : guanghe //文件引用方法:<script src="${staticPath}/common/js/dateUtil.js"></script> /** * 获取本周.本季度.本月.上月的开始日期.结束日期 */ var now = new Date(); //当前日期 var nowDayOfWeek = now.getDay(); //今天本周的第几天 var nowDa…
import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; /** * Created by xiaochun on 2016/3/24. */ public class TimeUtil { public static void main(String[] args) { System.out.println("当前小时开始:"+getCurrentHourStartTime…