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.