时间格式化,常用时间,格式

const formatData = () => {let time, YYYYMMDDnorm, YYYYMMDD, YYYY, MM, MMChinese, DD, HHMMSS;let now = new Date();let year = now.getFullYear();       //年let month = now.getMonth() + 1;     //月let day = now.getDate();            //日let hh = now.getHours();            //时let mm = now.getMinutes();          //分let ss = now.getSeconds();           //秒time = year + "-";YYYYMMDDnorm = year + "-";HHMMSS = "";MMChinese = ""YYYY = year;if (month < 10) {time += "0";time += month + "-";YYYYMMDDnorm += "0";YYYYMMDDnorm += month + "-";MM = "0" + month;} else {time += month + "-";YYYYMMDDnorm += month + "-";MM = month;}if (day < 10) {time += "0";time += day + " ";YYYYMMDDnorm += "0";YYYYMMDDnorm += day;DD = "0" + day;} else {time += day + " ";YYYYMMDDnorm += day;DD = day;}if (hh < 10) {time += "0";time += hh + ":";HHMMSS += "0";HHMMSS += hh + ":";} else {time += hh + ":";HHMMSS += hh + ":";}if (mm < 10) {time += '0';time += mm + ":";HHMMSS += "0";HHMMSS += mm + ":";} else {time += mm + ":";HHMMSS += mm + ":";}if (ss < 10) {time += '0';time += ss;HHMMSS += "0";HHMMSS += ss;} else {time += ss;HHMMSS += ss;}switch (MM) {case "01":MMChinese = "一月"breakcase "02":MMChinese = "二月"breakcase "03":MMChinese = "三月"breakcase "04":MMChinese = "四月"breakcase "05":MMChinese = "五月"breakcase "06":MMChinese = "六月"breakcase "07":MMChinese = "七月"breakcase "08":MMChinese = "八月"breakcase "09":MMChinese = "九月"breakcase "10":MMChinese = "十月"breakcase "11":MMChinese = "十一"breakcase "12":MMChinese = "十二"breakdefault:DDChinese = ""}YYYYMMDD = YYYYMMDDnorm.split('-').join('')return { time, YYYYMMDDnorm, YYYYMMDD, YYYY, MM, MMChinese, DD, HHMMSS }
}const formatDataTime = (time) => {var timeF = (new Date(time.replace(/-/g, '/').valueOf()));let now = new Date(timeF);// console.log(new Date(strtime).getFullYear())// console.log(new Date(strtime).getMonth() + 1)// console.log(new Date(strtime).getDate())let year = now.getFullYear();       // 年let month = now.getMonth() + 1;     // 月let day = now.getDate();            // 日let hh = now.getHours();            // 时let mm = now.getMinutes();          // 分let ss = now.getSeconds();           // 秒if (month < 10) {month = "0" + month;} else {month = month;}if (day < 10) {day = "0" + day;} else {day = day;}if (hh < 10) {hh += "0";} else {hh = hh;}if (mm < 10) {mm += "0";} else {mm = mm;}if (ss < 10) {ss += "0";} else {ss = ss;}switch (month) {case "01":month = "一月"breakcase "02":month = "二月"breakcase "03":month = "三月"breakcase "04":month = "四月"breakcase "05":month = "五月"breakcase "06":month = "六月"breakcase "07":month = "七月"breakcase "08":month = "八月"breakcase "09":month = "九月"breakcase "10":month = "十月"breakcase "11":month = "十一"breakcase "12":month = "十二"breakdefault:month = ""}return { year, month, day, hh, mm, ss}
}export {formatData,formatDataTime
}

时间格式化,常用时间,格式相关推荐

  1. mysql.h函数解释_mysql时间格式化函数日期格式h和H区别

    本文为博主原创,未经允许不得转载: 今天碰到一个问题,发现项目中有一个统计图的数据和时间格式没有对应准确,统计图要描述的是操作次数和操作时间的关系, 但很奇怪的是操作次数对应的时间却是凌晨,实际应用中 ...

  2. oracle时间格式化常用函数

    oracle时间格式化经常使用的两个函数: TO_CHAR(datetime, 'format') TO_DATE(character, 'format') Oracle支持的时间格式: Format ...

  3. java将从键盘输入的时间格式化_java 时间格式化中的模式字母

    java日期格式化中的模式字母有特定的意义,由于没有注意,今天在做工程的时候导致出现了奇怪的日期: 错误写法如下: 然而得到了错误的结果: 正确写法如下: 这样就得到了正确的结果 mm指的是分钟,MM ...

  4. js 格式化 java时间格式化_javascript时间格式化

    对于从后台数据库读取出来的时间格式有时并不是我们想要的格式. 要想使用java的SimpleDateFormat是实现不了时间格式化的,不过在在http://www.javascriptsource. ...

  5. Time时间格式化当前时间

    dateFormat:function() {var date=new Date();var year=date.getFullYear();/* 在日期格式中,月份是从0开始的,因此要加0* 使用三 ...

  6. python 时间格式化和时间比较

    前言: 工作中经常需要对时间做格式化处理,也有时候需要对各种格式的时间进行比较,这里简单梳理一下处理方法. 1.时间格式化 时间格式化涉及到不同类型的时间格式相互转换,其简单的思路就是规定一种通用时间 ...

  7. sqlserver mysql时间格式化_SqlServer时间格式化

    最近用的SqlServer比较多, 时间 格式化 老是忘记,现整理如下:(来源于网上,具体来源地址忘记了,归根到底MSDN吧) SELECT CONVERT(varchar(50), GETDATE( ...

  8. js当前时间格式化_JS时间格式化

    因为new Date().toLocaleString() 在安卓和ios上的格式不一致,所以尽量自己写format 生成一个时间数组 作为一个简单的举例,我序列化一周的时间对象 声明参数 let l ...

  9. MySQL、SQL Server、Hive对时间格式化

    文章目录 MySQL时间格式化 SQL Server时间格式化 Hive时间格式化 MySQL时间格式化 date_format() 这个函数是比较常用的 select date_format('20 ...

  10. 字符串格式化成时间格式_JAVA | 常用的日期/时间格式化方式

    引言   我们在开发过程中,在数据库中经常会看到beginTime.updateTime和endTime这些字段,这些可能是为了记录业务操作的某个时间.日期等信息.特此,总结一些在代码中常用的日期.时 ...

最新文章

  1. 鸿蒙OS:万物互联,方舟Compiler
  2. jquery textSlider 文字滚动
  3. expdp导出表结构_超强技术案例!86万张表迁移的优化历程
  4. LeetCode--Add Two Numbers
  5. NOIP2017普及组翻车记
  6. Kava将于下午2时重新启动Kava Chain
  7. suse使用ISO文件制作zypper源
  8. win7系统启用还原服务器,小编为你讲解win7系统提示服务器上的MSDTC不可用的还原方案...
  9. 计算机系统结构图并简述各个部件的作用,【计算机组成原理】计算机系统
  10. MediaRecorder录制音频文件
  11. 参与流片是一种怎样的体验?
  12. Squid 代理服务之反向代理服务器架构搭建
  13. 改变销售预测准确率的4个最佳实践!
  14. 【多校联赛】The Crime-solving Plan of Groundhog
  15. 不限机型,手机端实时玩转3D、混合现实,快手Y-tech有黑科技(已开源)
  16. ovf导入虚拟服务器,云主机 导入 ovf
  17. 什么是虚拟计算机集群
  18. 我在Blue Nile(蓝色尼罗河)上通过python爬取一百万颗钻石,最终选出心仪的一颗
  19. 信贷十条打响新一轮经济刺激第一枪
  20. 如何在MAC OS中使用HAXM?

热门文章

  1. 浅析Thinkphp3.0的行为扩展模式
  2. ZZULIOJ 1116: 删除元素
  3. 信息学奥赛一本通 1158:求1+2+3+...
  4. 信息学奥赛一本通 2061:【例1.2】梯形面积
  5. 信息学奥赛一本通(1227:Ride to Office)
  6. jedis操作set_使用Redis来进行缓存操作
  7. linux内核那些事之pg_data_t、zone结构初始化
  8. 0.5px边框,css及sass
  9. [Unity][FlowCanvas] FlowScript 搜索功能不可用的解决办法:更新 UnityEditor 的版本
  10. python将输入值转化为元组_Python实现将元组中的元素作为参数传入函数的操作