Conversion and calculation of JS time format and timestamp what day is the date after a few days

Source: Internet
Author: User

Convert Date to Timestamp

function Get_unix_time (time1) {
var newstr = time1.replace (/-/g, '/');
var date = new Date (NEWSTR);
var time_str = Date.gettime (). toString ();
Return time_str.substr (0, 10);
}

I. Time-conversion timestamp
function TransDate (endTime) {
var date=new date ();
Date.setfullyear (endtime.substring (0,4));
Date.setmonth (endtime.substring (5,7)-1);
Date.setdate (endtime.substring (8,10));
Date.sethours (endtime.substring (11,13));
Date.setminutes (endtime.substring (14,16));
Date.setseconds (endtime.substring (17,19));
Return Date.parse (Date)/1000;
}
Two. Timestamp conversion time
(1): Convert to 2011-3-16 16:50:43 format:

Function GetDate (tm) {
var tt=new Date (parseint (tm) *). toLocaleString (). Replace (/year | month/g, "-"). Replace (/day/g, "")
return TT;
}
(2): converted to March 16, 2011 16:50:43:

Function GetDate (tm) {
var tt=new Date (parseint (tm) *). toLocaleString ()
return TT;
}

(3): Convert to March 16, 2011 16:50

Function GetDate (tm) {
var tt=new Date (parseint (tm) *). toLocaleString (). substr (0,16);
return TT;
}

Calculate the date after a few days, JS days calculation, TIME calculation

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title> Calculate the date after a few days, JS days calculation, TIME calculation-www.jbxue.com</title>
<style type= "Text/css" >
<!--
Body {font-family: "Song body"; font-size:9pt; margin-top:0px; margin-left:0px; margin-right:0px}
A {color:black; font-size:9pt; font-weight:400; Text-decoration:none}
a:hover {color:red; font-size:9pt; font-weight:400; Text-decoration:underline}
a:active {font:9pt "song body"; cursor:hand; color: #FF0033}
-
</style>
<body>

<center><font color=red face= "Official script" size=6> record a few days after the date </font></center>
<center>
<table border=0 bordercolor=blue borderlight=green style= "border-collapse:collapse" cellpadding= "0" cellspacing= " 0 ">
&LT;TR&GT;&LT;TD align=center><font size=5 color=red face= "Arial, Helvetica, Sans-serif" ><strong> Below is the effect display area!&LT;/STRONG&GT;&LT;/FONT&GT;&LT;/TD&GT;&LT;/TR&GT;&LT;TR&GT;&LT;TD align=center> <script language= "JavaScript" >
<!--Begin
function AddDays (form) {
Daystoadd=document.form.daystoadd.value;
var now=new Date ();
var newdate=new Date ();
var newtimems=newdate.gettime () + (daystoadd*24*60*60*1000);
Newdate.settime (Newtimems);
Document.form.display.value=newdate.tolocalestring ();
}
End-To
</script>
<form name=form>
<input type=text name=daystoadd size=4 value=10 onfocus= "This.select ()" onmouseover= "This.focus ()" >
<input Type=button value= "The date will be:" onclick= "AddDays (this.form)" name= "button" >
<input type=text name= "display" size=20 value= "" >
</form>
</td></tr>
</table></center>
<center>
<script language= "JavaScript" >
<!--Hide
function Gohist (a)
{//www.jbxue.com
History.go (a);
}
-
</script></center>
</body>

Conversion and calculation of JS time format and timestamp what day is the date after a few days

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.