/** * 类说明 :以及获取当前周的周一和周日的日期,当前月第一个和最后一天的日期 * 日期格式化:格式参数 G 年代标志符 y 年 M 月 d 日 h 时 在上午或下午 (1~12) H 时 在一天中 (0~23) m 分 s 秒 S 毫秒 E 星期 D 一年中的第几天 F 一月中第几个星期几 w 一年中第几个星期 W 一月中第几个星期 a 上午 / 下午 标记符 k 时 在一天中 (1~24) K 时 在上午或下午 (0~11) z 时区 */
1. 概述 1.1 说明 在项目过程中,有时候需要默认展示一个月的查询条件,即当月的第一天和最后一天. 2. 代码 2.1 代码示例 直接调用getFirstAndLastDay()即可得到当月的第一天和最后一天. /** * 获取当前月份的第一天和最后一天 **/ function getFirstAndLastDay() { let now = new Date(); let strLink = "-"; let year = now.getFullYear(); let mont
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace WyfClass { public class tools { /// <summary> /// 得到本周第一天(以星期天为第一天) /// </summary> /// <param name="datetime"></param> /// &l
/** * 获取当前月的第一天 */function getCurrentMonthFirst(){ var date=new Date(); date.setDate(1); return date;}/** * 获取当前月的最后一天 */function getCurrentMonthLast(){ var date=new Date(); var currentMonth=date.getMonth(); var nextMonth=++currentMonth; var nextMont
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace WyfClass { public class tools { /// <summary> /// 得到本周第一天(以星期天为第一天) /// </summary> /// <param name="datetime"></param> /// &l
public class CalendarTest { public static void main(String[] args) { // 获取当前年份.月份.日期 Calendar cale = null; cale = Calendar.getInstance(); int year = cale.get(Calendar.YEAR); int month = cale.get(Calendar.MONTH) + 1; int day = cale.get(Calendar.DATE);