QQ咨询不加好友发不了信息,咨询前先加好友! → QQ:820896380 ×

js如何获得年月日

js如何获得年月日

如何在 JavaScript 中获取年月日

获取当前年月日:

使用 Date 对象的 getFullYear(), getMonth() 和 getDate() 方法。

const now = new Date();
const year = now.getFullYear();
const month = now.getMonth() + 1; // 月份从 0 开始,因此需要加 1
const day = now.getDate();

console.log(`${year}-${month}-${day}`);

给TA打赏
共{{data.count}}人
人已打赏
WEB前端

js如何把长字符串变短

2024-6-7 9:58:12

WEB前端

js如何获取滚动高度

2024-6-7 10:03:42

个人中心
购物车
优惠劵
有新私信 私信列表
搜索