JS implements the method of converting asp.net datetime JSON type to standard Time _javascript tips

Source: Internet
Author: User
Tags datetime time and date

This article illustrates the method of converting asp.net datetime JSON type to standard time by JS implementation. Share to everyone for your reference, specific as follows:

Directly on the example, as follows:

onload = function () {
  var thisdatetext = '/date (1401076829)/';
  document.write (Getlocaltime (Thisdatetext));
function Getlocaltime (datetext) {
  Datetext = Datetext.replace ("/date (", ""). Replace (")/", "");
  *
    Note:
      do not pass the Date in the string (such characters are also passed in, you have to deal with, so it is convenient to handle the
    use of the Replace method
    such as: replace ("/date"). Replace (")/", "" ");
  *
  //Return May 26, 2014 afternoon 12:00
  //return New Date (parseint (datetext) * 1000). toLocaleString (). replace (/:\d{1,2} $/, ' ');
  Return May 26, 2014 afternoon 12:0
  //return New Date (parseint (datetext) * 1000). toLocaleString (). substr (0);
  Returns 2014-5-26 12:00:29 return
  new Date (parseint (datetext) * 1000). toLocaleString (). Replace (/year | month/g, "-"). Replace (/day/g, ""). Replace (/a.m./g, ""). Replace (/PM/g, "");
}

PS: For JavaScript time and date display interested friends can also refer to the site online tools:

Unix timestamp (timestamp) conversion tool:
Http://tools.jb51.net/code/unixtime

Online Worldwide Time query:
Http://tools.jb51.net/zhuanhuanqi/worldtime

Online Perpetual calendar:
Http://tools.jb51.net/bianmin/wannianli

Web calendar:
Http://tools.jb51.net/bianmin/webwannianli

More about JavaScript related content to view the site topics: "JavaScript time and date Operation skills Summary", "JavaScript switching effects and techniques summary", "JavaScript Search Algorithm Skills summary", " JavaScript animation effects and tips Summary, "JavaScript Error and debugging skills Summary", "JavaScript data structure and algorithm skills summary", "JavaScript traversal algorithm and Skills summary" and "JavaScript Mathematical operation Usage Summary"

I hope this article will help you with JavaScript programming.

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.