JS need to turn the timestamp into a normal format, the general situation may not be used,
Let's see the first one here.
Copy Code code as follows:
function Getlocaltime (NS) {
return new Date (parseint (NS) * 1000). toLocaleString (). Replace (/:\d{1,2}$/, ' ");
}
Alert (Getlocaltime (1293072805));
The result is
December 23, 2010 10:53
Second Kind
Copy Code code as follows:
function Getlocaltime (NS) {
return new Date (parseint (NS) * 1000). toLocaleString (). substr (0,17)}
Alert (Getlocaltime (1293072805));
What if you want to get a format like this?
2010-10-20 10:00:00
Look at the code below.
Copy Code code as follows:
function Getlocaltime (NS) {
return new Date (parseint (NS) * 1000). toLocaleString (). Replace (/year | month/g, "-"). Replace (/day/g, "");
}
Alert (Getlocaltime (1177824835));
It can be written like this.
Copy Code code as follows:
function FormatDate (now) {
var year=now.getyear ();
var month=now.getmonth () +1;
var date=now.getdate ();
var hour=now.gethours ();
var minute=now.getminutes ();
var second=now.getseconds ();
return year+ "-" +month+ "-" +date+ "" +hour+ ":" +minute+ ":" +second; "
}
var d=new Date (1230999938);
Alert (FormatDate (d));
All right, problem solved.
It is to be noted that
Do not send a date (such as a character) in a string to be processed first, so it is convenient to handle
You can use the Replace method
As follows:
Copy Code code as follows:
Replace ("/date", ""). Replace (")/", "");