The database is clearly the time to return but become a string of irregular numbers. Workaround/** * Timestamp turn time format * @param jsondate the number of times to be obtained * * function__oracle

Source: Internet
Author: User
Tags getdate

The database is clearly the time to return but become a string of irregular numbers. Solving method

/**
* Time stamp Turn time format
* Number of times of @param jsondate
*/

function Getlocaltime (jsondate) {
Jsondate= "" +jsondate+ "";//Because Jsondate is a number type, indexof will complain.
if (Jsondate.indexof ("+") > 0) {
Jsondate = jsondate.substring (0, Jsondate.indexof ("+"));
}
else if (Jsondate.indexof ("-") > 0) {
Jsondate = jsondate.substring (0, Jsondate.indexof ("-"));
}
var date = new Date (parseint (Jsondate, 10));
var month = Date.getmonth () + 1 < 10? "0" + (date.getmonth () + 1): Date.getmonth () + 1;
var currentdate = date.getdate () < 10? "0" + date.getdate (): Date.getdate ();
var hours = date.gethours () < 10? "0" + date.gethours (): Date.gethours ();
var minutes = Date.getminutes () < 10? "0" + date.getminutes (): Date.getminutes ();
var seconds = date.getseconds () < 10? "0" + date.getseconds (): Date.getseconds ();
return date.getfullyear () + "-" + month + "-" + currentdate + "" + Hours + ":" + minutes + ":" + seconds;
}

Problem Solving (PS: One thing to note is that may be the number type, in JS can not use the IndexOf method, you need to add quotes into character creation format)

Reference http://www.bubuko.com/infodetail-832252.html

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.