Methods for processing timestamp as date format in JavaScript

Source: Internet
Author: User
Tags getdate

This article describes how to use the timestamp in JavaScript to date format, there is a good example, interested friends can refer to the following

The public processing timestamp function code is as follows:/** * processing timestamp converted to date format * @param {Object} obj timestamp {10-bit timestamp needs to be multiplied by 1000; 13-bit timestamp does not require} * @return {TypeName} return date format 2  013-09-16 */function Fullnum (obj) {if (number (obj) <) {return ' 0 ' + obj;  }else{return obj; } 1. The timestamp stored in PHP is 10 bits, and when JavaScript is processed it needs to be multiplied by 1000 to get the time code for the date format as follows: var mystime = newdate (MSG.PAGER.RESULT[I].ADSDA  TE * 1000);  var addstime = mystime.getfullyear () + '-' + fullnum (number (Mystime.getmonth ()) + 1) + '-' + fullnum (mystime.getdate ()); Addstime shows the time is 2013-09-16 2. The timestamp stored in Java is 13 bits, so the time code for the date format is as follows in JavaScript processing without any processing: var mystime = newdate (msg  . pager.result[i].adsdate);  var addstime = mystime.getfullyear () + '-' + fullnum (number (Mystime.getmonth ()) + 1) + '-' + fullnum (mystime.getdate ()); Direct use of addstime can be 2013-09-16
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.