JavaScript基础知识-Date对象

2019-06-26  本文已影响0人  aeborah

创建用法

var myDate = new Date();

对象属性

constructor
prototype

对象方法

getDate()---从 Date 对象返回一个月中的某一天 (1 ~ 31)。
getDay()---从 Date 对象返回一个月中的某一天 (1 ~ 31)。
getMonth() ---从 Date 对象返回月份 (0 ~ 11)。
getFullYear()---从 Date 对象以四位数字返回年份。
getHours()---返回 Date 对象的小时 (0 ~ 23)。
getMinutes()---返回 Date 对象的分钟 (0 ~ 59)。
getSeconds()--返回 Date 对象的秒数 (0 ~ 59)。
getUTCDate()---根据世界时从 Date 对象返回月中的一天 (1 ~ 31)。getUTCDay()--根据世界时从 Date 对象返回周中的一天 (0 ~ 6)。
getUTCMonth()---根据世界时从 Date 对象返回月份 (0 ~ 11)。
getUTCFullYear()--根据世界时从 Date 对象返回四位数的年份。
**set是正好相反的
toString()--把 Date 对象转换为字符串。
toDateString()--把 Date 对象的日期部分转换为字符串。
toTimeString()--把 Date 对象的时间部分转换为字符串。
toUTCString()--根据世界时,把 Date 对象转换为字符串。
toLocaleString()--根据本地时间格式,把 Date 对象转换为字符串。
value

上一篇 下一篇

猜你喜欢

热点阅读