dateUtils.js 877 B

123456789101112131415161718192021222324252627282930
  1. import dayjs from 'dayjs'
  2. /**
  3. * 检查当前时间是否在7月28号零点之后
  4. * @returns {boolean} 如果在7月28号零点之后返回true,否则返回false
  5. */
  6. export function isAfterJuly28() {
  7. const now = new Date();
  8. const july28 = new Date(2025, 6, 28, 0, 0, 0); // 月份从0开始,所以7月是6
  9. return now >= july28;
  10. }
  11. /**
  12. * 检查当前时间是否在指定日期之后
  13. * @param {Date} targetDate 目标日期
  14. * @returns {boolean} 如果在目标日期之后返回true,否则返回false
  15. */
  16. export function isAfterDate(targetDate) {
  17. const now = new Date();
  18. return now >= targetDate;
  19. }
  20. /**
  21. * 转换时间格式 默认不带时分秒
  22. * @param {Date} date 日期
  23. * @param format 自定义转换格式
  24. * @returns {string} 日期字符串
  25. */
  26. export function formatDate(date,format) {
  27. return dayjs(date).format(format?format:'YYYY-MM-DD')
  28. }