Example of common methods for Date objects in JavaScript: javascriptdate

Source: Internet
Author: User

Example of common methods for Date objects in JavaScript: javascriptdate

GetFullYear ()
Use getFullYear () to obtain the year.
Source code:

</script><!DOCTYPE html>

Test results:

2015


GetTime ()
GetTime () returns the number of milliseconds since January 1, January 1, 1970.
Source code:

<!DOCTYPE html>


Test results:

1445669203860

SetFullYear ()
How to Use setFullYear () to set a specific date.
Source code:

<!DOCTYPE html>

Test results:

Tue Nov 03 2020 14:47:46 GMT + 0800 (Chinese Standard Time)

ToUTCString ()
How to Use toUTCString () to convert the date of the current day (based on UTC) to a string.

Source code:

<!DOCTYPE html>

Test results:

Sat, 24 Oct 2015 06:49:05 GMT

GetDay ()
How to Use getDay () and array to display the week, not just a number.
Source code:

<!DOCTYPE html>

 

Test results:

Saturday

Display a clock
How to display a clock on a webpage.
Source code:

<!DOCTYPE html>


Related Article

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.