14.获取日期

1.   //获取当前时间

function getCurrentMonthFirst() {

  var date = new Date();

  var todate = date.getFullYear() + "-" + ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth()+1) + "-" + (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate());

  return todate;

}



2./**

   * 传入时间后几天

   * param:传入时间:dates:"2018-04-02",later:往后多少天

   */

function dateLater(dates, later) {

  let dateObj = {};

  let show_day = new Array('周日', '周一', '周二', '周三', '周四', '周五', '周六');

  let date = new Date(dates);

  date.setDate(date.getDate() + later);

  let day = date.getDay();

  dateObj.year = date.getFullYear();

  dateObj.month = ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth()+1);

  dateObj.day = (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate());

  dateObj.week = show_day[day];

  return dateObj;

}



3.获取指定日期的节假日信息

1、接口地址:http://api.goseek.cn/Tools/holiday?date=数字日期,支持https协议。 
2、返回数据:工作日对应结果为 0, 休息日对应结果为 1, 节假日对应的结果为 2 
3、节假日数据说明:本接口包含2017年起的中国法定节假日数据,数据来源国务院发布的公告,每年更新1次,确保数据最新 
4、示例: 
http://api.goseek.cn/Tools/holiday?date=20170528 

转链接https://blog.csdn.net/a9925/article/details/80743374
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容