WeChat mini-app time formatting (util. formatTime (new Date) details, WeChat mini-app util. js

Source: Internet
Author: User

Detailed description of the applet time formatting (util. formatTime (new Date), and the applet util. js

Small Program time formatting

Although the mini-program is still in beta testing, it is not enough. Hurry up and record the learning path.

Obtain the time by using Date. now () to obtain a string of numbers. For example:

Use util. formatTime (new Date) to obtain the formatted time)

Util is a tool provided in the official demo:

Function formatTime (date) {var year = date. getFullYear () var month = date. getMonth () + 1 var day = date. getDate () var hour = date. getHours () var minute = date. getMinutes () var second = date. getSeconds () return [year, month, day]. map (formatNumber ). join ('/') + ''+ [hour, minute, second]. map (formatNumber ). join (':')}

The obtained time is as follows:

Thank you for reading this article. I hope it will help you. Thank you for your support for this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.