How to get the current date in the applet

王林
Release: 2021-01-15 10:04:49
forward
4693 people have browsed it

How to get the current date in the applet

Implementation code:

(Learning video sharing:Programming video)

var timestamp = Date.parse(new Date()); var date = new Date(timestamp); //获取年份 var Y =date.getFullYear(); //获取月份 var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1); //获取当日日期 var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate(); console.log("当前时间:" + Y + '年' + M+ '月' + D+ '日' );
Copy after login

console.log("Current time: " Y 'Year' M 'Month' D 'Day' );

The print results are as follows:

How to get the current date in the applet

Related recommendations:Small Program Development Tutorial

The above is the detailed content of How to get the current date in the applet. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!