Time conversion in JS-millisecond conversion to date Time sample code

Source: Internet
Author: User
Tags time and seconds

This article is mainly to JS in the time conversion-millisecond conversion to date time of the sample code is introduced, need friends can come to the reference, I hope to help you

The JS millisecond time is converted to the date time code as follows: var oldtime = (New Date ("2011/11/11 20:10:10")). GetTime ();   Get the number of milliseconds is mostly in milliseconds divided by 365*24*60*60&1000, so turn back, this method conversion is too complex, month, time and seconds are to be different methods to obtain, and some years have 366 days, some 365 days, so it is too complicated. After you tried a method, incredibly successful the code is as follows: var oldtime = (New Date ("2011/11/11 20:10:10")). GetTime (); Gets the millisecond number var newtime = new Date (oldtime); You get the normal time. Direct incoming milliseconds as an argument, giving the date object the usual time, and then getting the date by gethours,getfullyear and so on.

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.