Henry Henry
  • JavaScript
  • TypeScript
  • Vue
  • ElementUI
  • React
  • HTML
  • CSS
  • 技术文档
  • GitHub 技巧
  • Nodejs
  • Chrome
  • VSCode
  • Other
  • Mac
  • Windows
  • Linux
  • Vim
  • VSCode
  • Chrome
  • iTerm
  • Mac
  • Obsidian
  • lazygit
  • Vim 技巧
  • 分类
  • 标签
  • 归档
  • 网站
  • 资源
  • Vue 资源
GitHub (opens new window)

Henry

小学生中的前端大佬
  • JavaScript
  • TypeScript
  • Vue
  • ElementUI
  • React
  • HTML
  • CSS
  • 技术文档
  • GitHub 技巧
  • Nodejs
  • Chrome
  • VSCode
  • Other
  • Mac
  • Windows
  • Linux
  • Vim
  • VSCode
  • Chrome
  • iTerm
  • Mac
  • Obsidian
  • lazygit
  • Vim 技巧
  • 分类
  • 标签
  • 归档
  • 网站
  • 资源
  • Vue 资源
GitHub (opens new window)
  • JavaScript

    • js 编码指南
    • 日期使用斜杠 点 中划线分隔的不同
    • forEach 会改变原数组值吗
    • 前端表单验证常用的正则表达式 - reg
    • JS 如何取得 URL 里的参数
    • JavaScript 数组去重
    • JavaScript 循环中断研究与总结-关键字篇
    • JavaScript 循环中断研究与总结-用法篇
    • js 中的 Error
    • 跳出 forEach
    • Location 对象
    • Date 方法预览
    • Reg 正则中的问题
    • JavaScript toFixed() 方法
    • query 和 params 的使用区别
    • axios post 请求中下载文件流
    • 实用的 js 技巧
    • JS 之数组的几个不 low 操作
    • 深入浅出深拷贝与浅拷贝
    • 如何实现一个深拷贝
    • 使用 iframe 中的一些问题
    • 在 js 中更好地使用数组
    • echarts 在坐标轴两侧各增加一格坐标
    • 从头认识js的事件循环模型
    • moment 根据周截至日算出指定月有几周及开始结束日期
    • 正则 reg 中 /number 的用法
    • 正则 reg 中 match 和 exec 异同
  • TypeScript

  • Vue

  • ElementUI

  • React

  • AntD

  • 前端
  • JavaScript
Henry
2017-07-25

Date 方法预览

Date 自带很多将 Date 对象转换为字符串的格式化方法, 这里将各个方法转换后的结果收集为表格, 方便查看

方法 描述 预览
toString() (opens new window) 把 Date 对象转换为字符串.
toTimeString() (opens new window) 把 Date 对象的时间部分转换为字符串.
toDateString() (opens new window) 把 Date 对象的日期部分转换为字符串.
toGMTString() (opens new window) 请使用 toUTCString() 方法代替.
toUTCString() (opens new window) 根据世界时, 把 Date 对象转换为字符串.
toLocaleString() (opens new window) 根据本地时间格式, 把 Date 对象转换为字符串.
toLocaleTimeString() (opens new window) 根据本地时间格式, 把 Date 对象的时间部分转换为字符串.
toLocaleDateString() (opens new window) 根据本地时间格式, 把 Date 对象的日期部分转换为字符串.
toISOString() (opens new window) 把一个日期转换为符合 ISO 8601 扩展格式的字符串.
toJSON() (opens new window) 使用 toISOString() (opens new window) 返回一个表示该日期的字符串. 为了在 JSON.stringify() (opens new window) 方法中使用.
Date() (opens new window) 返回当日的日期和时间.
getDate() (opens new window) 从 Date 对象返回一个月中的某一天 (1 ~ 31).
getDay() (opens new window) 从 Date 对象返回一周中的某一天 (0 ~ 6).
getMonth() (opens new window) 从 Date 对象返回月份 (0 ~ 11).
getFullYear() (opens new window) 从 Date 对象以四位数字返回年份.
getYear() (opens new window) 请使用 getFullYear() 方法代替.
getHours() (opens new window) 返回 Date 对象的小时 (0 ~ 23).
getMinutes() (opens new window) 返回 Date 对象的分钟 (0 ~ 59).
getSeconds() (opens new window) 返回 Date 对象的秒数 (0 ~ 59).
getMilliseconds() (opens new window) 返回 Date 对象的毫秒(0 ~ 999).
getTime() (opens new window) 返回 1970 年 1 月 1 日至今的毫秒数.
getTimezoneOffset() (opens new window) 返回本地时间与格林威治标准时间 (GMT) 的分钟差.
getUTCDate() (opens new window) 根据世界时从 Date 对象返回月中的一天 (1 ~ 31).
getUTCDay() (opens new window) 根据世界时从 Date 对象返回周中的一天 (0 ~ 6).
getUTCMonth() (opens new window) 根据世界时从 Date 对象返回月份 (0 ~ 11).
getUTCFullYear() (opens new window) 根据世界时从 Date 对象返回四位数的年份.
getUTCHours() (opens new window) 根据世界时返回 Date 对象的小时 (0 ~ 23).
getUTCMinutes() (opens new window) 根据世界时返回 Date 对象的分钟 (0 ~ 59).
getUTCSeconds() (opens new window) 根据世界时返回 Date 对象的秒钟 (0 ~ 59).
getUTCMilliseconds() (opens new window) 根据世界时返回 Date 对象的毫秒(0 ~ 999).
parse() (opens new window) 返回1970年1月1日午夜到指定日期(字符串)的毫秒数.
setDate() (opens new window) 设置 Date 对象中月的某一天 (1 ~ 31).
setMonth() (opens new window) 设置 Date 对象中月份 (0 ~ 11).
setFullYear() (opens new window) 设置 Date 对象中的年份(四位数字).
setYear() (opens new window) 请使用 setFullYear() 方法代替.
setHours() (opens new window) 设置 Date 对象中的小时 (0 ~ 23).
setMinutes() (opens new window) 设置 Date 对象中的分钟 (0 ~ 59).
setSeconds() (opens new window) 设置 Date 对象中的秒钟 (0 ~ 59).
setMilliseconds() (opens new window) 设置 Date 对象中的毫秒 (0 ~ 999).
setTime() (opens new window) 以毫秒设置 Date 对象.
setUTCDate() (opens new window) 根据世界时设置 Date 对象中月份的一天 (1 ~ 31).
setUTCMonth() (opens new window) 根据世界时设置 Date 对象中的月份 (0 ~ 11).
setUTCFullYear() (opens new window) 根据世界时设置 Date 对象中的年份(四位数字).
setUTCHours() (opens new window) 根据世界时设置 Date 对象中的小时 (0 ~ 23).
setUTCMinutes() (opens new window) 根据世界时设置 Date 对象中的分钟 (0 ~ 59).
setUTCSeconds() (opens new window) 根据世界时设置 Date 对象中的秒钟 (0 ~ 59).
setUTCMilliseconds() (opens new window) 根据世界时设置 Date 对象中的毫秒 (0 ~ 999).
toSource() (opens new window) 返回该对象的源代码.
UTC() (opens new window) 根据世界时返回 1970 年 1 月 1 日 到指定日期的毫秒数.
valueOf() (opens new window) 返回 Date 对象的原始值.
编辑 (opens new window)
#Js#Date
上次更新: 5/27/2023, 1:02:05 PM
Location 对象
Reg 正则中的问题

← Location 对象 Reg 正则中的问题→

最近更新
01
version 1.15
07-01
02
version 1.14
06-27
03
version 1.13
06-27
更多文章>
Theme by Vdoing | Copyright © 2017-2023 HenryTSZ | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式