最近專案中使用了大量關於日期的操作遂將其整理如下:
/** * 格式化日期
* @param fmt [日期型別 預設為年月日(yyyy-mm-dd)] */
date.prototype.format = function (fmt = 'yyyy-mm-dd') ;
if (/(y+)/.test(fmt))
for (var key in
date)
}return
fmt;}/*
* * 返回帶有時區的時間
* @param fmt [日期型別 預設為年月日(yyyy-mm-dd hh:mm:ss)] */
date.prototype.getutctime = function (format = 'yyyy-mm-dd hh:mm:ss') /**
* 獲取當前月的最後一天
* @param fmt [日期型別 預設為年月日(yyyy-mm-dd)]
*/date.prototype.getcurrentmonthlast = function (format = 'yyyy-mm-dd') /**
* 獲取當前月的第一天
* @param fmt [日期型別 預設為年月日(yyyy-mm-dd)]
*/date.prototype.getcurrentmonthfirst = function (format = 'yyyy-mm-dd')
PHP 日期格式化(獲取上月第一天 最後一天等)
1.獲取上個月第一天及最後一天.echo date y m 01 strtotime 1 month echo echo date y m t strtotime 1 month echo 2.獲取當月第一天及最後一天.begindate date y m 01 strtotime date y m...
PHP 日期格式化(獲取上月第一天 最後一天等)
1.獲取上個月第一天及最後一天.echo date y m 01 strtotime 1 month echo echo date y m t strtotime 1 month echo 2.獲取當月第一天及最後一天.begindate date y m 01 strtotime date y m...
利用Calendar 獲取當月1號,最後一天
dateformat format new dateformat yyyy mm dd 獲取前月的第一天 calendar cal 1 calendar.getinstance 獲取當前日期 cal 1.add calendar.month,1 cal 1.set calendar.day of m...