jquery add time and time stamp to convert components to each other

Source: Internet
Author: User
Tags add time

The time-to-timestamp format is converted to each other (conversion primary compatible IE8,IE8 does not support new Date ())

(function ($) {$.extend ({myTime: {curtime:function () } {returnDate.parse (NewDate ())/1000;}, Datetounix:function (string) {//time-to-timestamp var f= String.Split ("', 2); var d= (F[0]? F[0]: '). Split ('-', 3); var t= (F[1]? F[1]: '). Split (': ', 3); return(NewDate (parseint (d[0], 10) | |NULL, (parseint (d[1], ten) | | 1)-1, parseint (d[2], 10) | |NULL, parseint (T[0], 10) | |NULL, parseint (t[1], 10) | |NULL, parseint (t[2], 10) | |NULL). GetTime ()/1000;},
Unixtodate:function (Unixtime, Isfull, TimeZone) {//timestamp turn time
if(typeof (TimeZone) = = ' number ') {
Unixtime = parseint (unixtime) + parseint (timeZone) * 60 * 60;
}
var time =NewDate (Unixtime);
var ymdhis = "";
Ymdhis + = Time.getutcfullyear () + "-";
Ymdhis + = (time.getutcmonth () + 1) + "-";
Ymdhis + = Time.getutcdate ();
if(Isfull = = ' true ') {
Ymdhis + = "+ time.getutchours () +": ";
Ymdhis + = time.getutcminutes () + ":";
Ymdhis + = Time.getutcseconds ();
}
returnymdhis;}}); }) (JQuery);

jquery add time and time stamp to convert components to each other

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.