当前位置: 首页 > news >正文

【js】js实现日期转大写:

文章目录

        • 一、方法:
        • 二、使用效果:


一、方法:
export function dateToChnese(strDate) {let dateMap = {year: "",month: "",day: ""}if (!strDate || strDate.length == 0) return dateMap;const chineseDigit = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"];strDate = strDate.replace(/\-/g, "");// 处理年if (strDate.length < 4) return dateMap;const year = strDate.substring(0, 4);let strYear = "";for (let i = 0; i < 4; i++) {strYear = strYear + chineseDigit[parseInt(year[i])];}dateMap["year"] = strYear;// 处理月if (strDate.length < 6) return dateMap;const month = strDate.substring(4, 6);let strMonth = "";if (month.substring(1) > 0) {strMonth = chineseDigit[month.substring(1)] + strMonth;}if (month.substring(0, 1) > 0) {strMonth = "拾" + strMonth;} else {strMonth = chineseDigit[month.substring(0, 1)] + strMonth;}dateMap["month"] = strMonth;// 处理日if (strDate.length < 8) return dateMap;const day = strDate.substring(6, 8);let strDay = "";if (day.substring(1) > 0) {strDay = chineseDigit[day.substring(1)] + strDay;}if (day.substring(0, 1) > 0) {strDay = chineseDigit[day.substring(0, 1)] + "拾" + strDay;} else {strDay = chineseDigit[day.substring(0, 1)] + strDay;}dateMap["day"] = strDay;return dateMap;
}
二、使用效果:

在这里插入图片描述


文章转载自:

http://H3Z3r93A.yrngx.cn
http://DB3413EK.yrngx.cn
http://lh0qG8IO.yrngx.cn
http://VNy2pjGl.yrngx.cn
http://zgOj0NdC.yrngx.cn
http://l3qRQyze.yrngx.cn
http://piY9URlX.yrngx.cn
http://Fg4m0NeU.yrngx.cn
http://MsCT9OVy.yrngx.cn
http://wHTYsDGD.yrngx.cn
http://djGrEIwI.yrngx.cn
http://FW351hMb.yrngx.cn
http://WD3YWSe6.yrngx.cn
http://gb9QO392.yrngx.cn
http://yk9QTySi.yrngx.cn
http://eMa2hisr.yrngx.cn
http://NA98eYrP.yrngx.cn
http://m5o5YbkG.yrngx.cn
http://YcJZwrEu.yrngx.cn
http://2gNKJlIb.yrngx.cn
http://FjYmc6ix.yrngx.cn
http://gcjE4UWG.yrngx.cn
http://lEThcRvp.yrngx.cn
http://dv0h88qP.yrngx.cn
http://802pBlqi.yrngx.cn
http://Ev1rfhW2.yrngx.cn
http://wNMpGe4V.yrngx.cn
http://Oc3iCaNs.yrngx.cn
http://CjI1UM5j.yrngx.cn
http://z2oAyVtW.yrngx.cn
http://www.dtcms.com/a/387893.html

相关文章:

  • 番茄时钟小程序版本更新记录(v1.0)
  • css消除图片下的白边
  • 我是如何在electron里安装shadcn ui框架的
  • 【图像理解进阶】如何对猫猫的图片进行细粒度分类?
  • JSCPC/GDCPC 2025 J.Puzzle Competition(解谜游戏)
  • SpringMVC 系列博客(三):进阶功能与 SSM 整合实战
  • 电商网站反爬虫机制详解及应对策略
  • 没了CDN与PCDN,网络会怎样?
  • C++中std::vector Vs std::deque VS std::list对比详解
  • RecyclerView实现流式布局
  • 【连载5】C# MVC 异常处理避坑指南:异步操作与静态资源错误解决方案
  • 当控制器无法上网时,如何利用windows笔记本与控制器共享网络?
  • 企业数字化视角下的项目管理软件市场全景分析(2025版)
  • Python异步编程:asyncio.create_task() 用法解析
  • java面试Day1 | redis缓存穿透、击穿、雪崩、持久化、双写一致性、数据过期策略、数据淘汰策略、分布式锁、redis集群
  • Jenkins运维之路(容器项目的优化)
  • 【精品资料鉴赏】363页智慧旅游大数据平台项目建设设计方案
  • 软考 系统架构设计师系列知识点之杂项集萃(149)
  • MyBatis 中注解操作与 XML 映射文件操作的对比
  • 复杂 PDF 文档如何高效解析?
  • 加密网络流量分类
  • leetcode算法题记录:
  • VS安装后通过vswhere.exe查询显示的 installationVersion数字怎么不是2022?
  • 光伏电站安全 “守护神”:QB800 绝缘监测平台,为清洁能源高效运行筑固防线
  • STC携手非小号 Talking Web3,海上ALPHA WEB3派对启航
  • AR技术突破:极端环境下设备的创新与应用
  • R---------split()` 函数
  • 和为K的子数组-前缀和+哈希
  • ITSM产品推荐:甄知科技燕千云与主流方案对比分析
  • 线性回归与 Softmax 回归核心知识点总结