/**

  • 根据传入的时间格式,返回对应的选择器时间格式
  • @param {string} format - 时间格式字符串
  • @returns {string} - 选择器时间格式字符串 */ function getSelectorTimeFormat(format) { // 如果时间格式中包含'h'或'hh',并且包含'a'或'A' if (format.search(/h{1,2}/) > -1 && format.search(/[aA]/) > -1) { // 如果时间格式中包含'A' if (format.search(/[A]/) > -1) { return 'hh:mm A'; // 返回'hh:mm A' } else { return 'hh:mm a'; // 返回'hh:mm a' } } return 'HH:mm'; // 返回'HH:mm' }
JavaScript 获取选择器时间格式函数

原文地址: https://www.cveoy.top/t/topic/oK9U 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录