yxdate

功能描述

YXDate 该模块封装了一套时工具类 时间戳转换成指定格式时间、倒计时、获取当前星期几等

依赖模块

快速使用

主要Api: 1、getTimesAutoFormat(timestamp) //根据传入时间戳自动转化成时间格式 参数说明: timestamp: 传入时间戳

  1. /**
  2. * 根据传入时间戳自动转化成时间格式
  3. * 距离当前时间不足一天时显示: hh:mm --> eg: 13:14
  4. * 距离当前时间不足一年时显示: MM-dd hh:mm --> eg: 06-10 13:14
  5. * 距离当前时间超过一年时显示: yyyy-MM-dd hh:mm --> eg: 2018-06-10 13:14
  6. */
  7. YXDate.getTimesAutoFormat(timestamp)

2、 getNowTimesToFormat(format) 根据当前时间戳转换成指定格式

  1. 参数说明: format 传入时间格式 例如'yyyy-MM-dd hh:mm' , 'yyyy年MM月dd hh:mm'
  2. /**
  3. * 根据当前时间戳转换成指定格式
  4. * timestamp 时间戳
  5. * format 时间格式 yyyy-MM-dd hh:mm
  6. */
  7. YXDate.getNowTimesToFormat(format)

3、 getTimesToFormat //根据时间戳转换成指定格式

  1. /**
  2. * 根据时间戳转换成指定格式
  3. * timestamp 时间戳
  4. * format 时间格式 yyyy-MM-dd hh:mm
  5. */
  6. YXDate.getTimesToFormat(timestamp,format)

4、 getTimestrmpToMD(timestamp)

  1. 参数说明: timestamp 传入参数时间戳
  2. /**
  3. * 根据时间戳转换成 上午下午指定格式
  4. * timestamp 时间戳
  5. */
  6. YXDate.getTimestrmpToMD(timestamp)

5、 countDown(timestamp,callBack)

  1. 参数说明: timestamp 传入时间戳
  2. callBack 回调
  3. /**
  4. * 倒计时
  5. * 传入时间戳读秒倒计时
  6. * timestamp 时间戳
  7. * callBack 回调 直接返回的秒数
  8. */
  9. YXDate.countDown: function(timestamp,callBack)

6、 week(timestamp)

  1. 参数说明:timestamp 传入时间戳
  2. /**
  3. * 根据时间戳 获取当前星期几
  4. */
  5. YXDate.week(timestamp)