Loading... ## 获取当前时间 ```javascript function timeDate(){ let timestamp = Date.parse(new Date()); let date = new Date(timestamp); //获取年 let Y = date.getFullYear(); //获取月 let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1); //获取当日 let D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate(); return (Y + '年' + M + '月' + D + '日'); } ``` 最后修改:2022 年 03 月 31 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 0 如果文章有用,请随意打赏。