Grabe uno que encontré. La solicitud de publicación en MVC devuelve una cadena JSON que contiene el formato de tiempo en la base de datos (como: /date (10000000000) /). No sé cómo lidiar con eso.
Los métodos de Baidu no son aplicables. Después de investigarlo yo mismo, ha hecho un complemento jQuery, con la esperanza de que sea útil para todos.
Código fuente del complemento:
(función ($) {/formato El tipo de fecha devuelto por JSON es el formato definido por sí mismo: por ejemplo: aaa yyyy-mm-dd hh: mm: ssdtstr: la fecha devuelta por json "/date (1000000000)/"* fmt: formato personalizado, como: yyyyyy-mm dd hh: mm: ss/$. $ .TodateTime (dstr); var o = {"m+": date.getMonth ()+1, // mes "d+": date.getDate (), // day "H+": date.gethours (), // hora "h+": date.gethours (), // hora "m+": date.getMinutes (), // min "s+" s+"stet.gets () // segundo "Q +": Math.floor ((date.getMonth () + 3)/3), // trimestralmente "s": date.getMilliseConds () // MilliseConds}; if (/(y+)/.test(fmt)) fmt = fmt.replace (Regexp. $ 1, (date.gettyfulfyear () + "") "). Regexp. $ 1.Length))); for (var k en o) if (nuevo regexp ("(" + k + ")"). Test (fmt)) fmt = fmt.replace (regexp. $ 1, (regexp. $ 1.length == 1)? (O [k]): ("00" + o [k]). Substr (((("" "" "" "" o [k]). longitud))); return fmt;}/format json devuelve el tipo de fecha de fecha larga hasta la fecha: json devuelve fecha "/date(1000000000000)/"/$.todateTime = function (dstr) {// 1900-01-01t00: 00: 00if ((dtr + '') .indexof ('date (')> = 0) + (dstr + '') .replace ('/date (', '') .replace (')/', ''); if (ldate> 0) {return new Date (ldate); (str.split ('.') [0] == '1900/01/01 00:00:00:00') {return null;} else if ((dstr + '' ') .length> 0) {return New Date (str.split ('. '.') [0]);}} return null;}/Format json regresa el tipo de fecha largo a la cadena de format especificada: 2015-01- 12:59:59title: Date type name "Publish time" dtstr: JSON Returns Date "/Date(10000000000)/" substrstart: String start truncation position "5"/$.ToDateTimeString = function (title, dstr, substrstart) {var dt = toDateTime(dstr);if (dt) {var y = dt.getFullYear();var m = dt.getmonTh () + 1; var d = dt.getDate (); var h h = dt.gethours (); var i = dt.gethours (); var s = dt.gethours (); var datStr = y + "--" + (m <10? "0": "" ") + m +"-"(dt.get.getDate () dt.getDate () + "" + (dt.gethours () <10? "0": "") + dt.gethours () + ":" + (dt.getminutes () <10? "0": "") + dt.getminutes () + ":" + (dt.getSeconds () <10? "0": ") (dt.getSeconds () <10? "0": "") + dt.getSeconds (); Título: Tipo de fecha Nombre "Tiempo de publicación" DTSTR: JSON Devuelve Fecha "/Fecha (100000000000)/" DTSTR01: JSON Devuelve Fecha "/Fecha (1000000000000)/" Diferencia de tiempo Fecha de finalización 1DTSTR02: JSON Fecha de devoluciones "/Fecha (100000000000000)/" Diferencia de tiempo Fecha de finalización 2 Si 1SubstrStart está vacío: la cadena comienza la posición de la cadena "5". función (htmls, title, dtstr, dtstr01, dtstr02, substrStart) {var dtstrs = tOdateTiMeString ("", dtstr, substrstart); if (dtstrs) {var dt1 = toDateTime (dstr); var dt2 = toDatetime (dstr01); var dt3 = TODATETIME (DSTR02); if (dt3) {dt2 = dt3; "Seconds": "") + "" + dtstrs + '' ');}}}) (jQuery); Time Formatting jQuery complementoCómo usar
1. Cita el complemento jQuery anterior
2. Tiempo de formato:
$ .post ("/tigger/getUserPrizeLog? t =" +Math.random (), {ActivityCode: 1138, myopenid: " class =/"Title/"> " + Model.ActivityPrizeName +" </p> "; str + =" <p class =/"time/"> " + $ .Format (model.createTime," yyyy-mm-dd hh: mm ") +" </p> "; "')/"> </span> "; str +=" </li> ";}); $ ("#registro ul "). html (str);});Model.CreateTime es el tiempo obtenido del servidor
Cómo usar:
$ .Format (Model.CreateTime, "Yyyy-MM-DD HH: MM")
El artículo anterior en profundidad de la comprensión del formato de tiempo JS en MVC es todo el contenido que comparto con usted. Espero que pueda darle una referencia y espero que pueda apoyar más a Wulin.com.