This question already has an answer here: How do I format a Microsoft JSON date? 37 answers function getDate(str){ // extract number from string using regex var stringNum = str.match(/d+/)[0]; // turn number into int var intNum = stringNum * 1; // turn int into date return new Date(intNum); var str = '/Date(1451599200000)/'; alert(getDate(str));
这个问题在这里已经有了答案: 如何格式化Microsoft JSON日期? 37个答案 function getDate(str){ // extract number from string using regex var stringNum = str.match(/d+/)[0]; // turn number into int var intNum = stringNum * 1; // turn int into date return new Date(intNum); var str = '/Date(1451599200000)/'; alert(getDate(str));
This question already has an answer here: How do I format a Microsoft JSON date? 37 answers You can try this code //DEFINE THE FUNCTION TO GET DATE FROM MILISECOND var format = function (time, format) { var t = new Date(time); var tf = function (i) { return (i < 10 ? '0' : '') + i }; return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function (a) {
这个问题在这里已经有了答案: 如何格式化Microsoft JSON日期? 37个答案 你可以试试这个代码 //DEFINE THE FUNCTION TO GET DATE FROM MILISECOND var format = function (time, format) { var t = new Date(time); var tf = function (i) { return (i < 10 ? '0' : '') + i }; return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function (a) { switch (a) {
This question already has an answer here: How do I format a Microsoft JSON date? 37 answers var arr=time.split(' '); var date_arr=arr[0]; var time_arr=arr[1]; var temp_date=date_arr.split('-'); var temp_time=time_arr.split(':'); var js_date=temp_date[2]+'.'+temp_date[1]+'.'+temp_date[0]+' '+temp_time[0]+":"+temp_time[1]; You need to do all by your hands. Javascript's Date object has
这个问题在这里已经有了答案: 如何格式化Microsoft JSON日期? 37个答案 var arr=time.split(' '); var date_arr=arr[0]; var time_arr=arr[1]; var temp_date=date_arr.split('-'); var temp_time=time_arr.split(':'); var js_date=temp_date[2]+'.'+temp_date[1]+'.'+temp_date[0]+' '+temp_time[0]+":"+temp_time[1]; 你需要用手完成所有事情。 Javascript的Date对象有足够的方法。 所以请尝试像这样: var date
Possible Duplicate: How to format a JSON date? I have a JSON that contains some dates that I need to be in a UTC format. At present if I alert the dates out they are in the following format: /Date(1329314400000)/ I am trying to loop round the JSON but am unsure on how to convert the above date format to UTC. If anyone has any advice I would greatly appreciate it. 检查出来:如何格式化
可能重复: 如何格式化JSON日期? 我有一个JSON包含一些日期,我需要在UTC格式。 目前,如果我提醒日期,它们的格式如下: /日期(1329314400000)/ 我试图循环JSON,但我不确定如何将上述日期格式转换为UTC。 如果有人有任何建议,我将不胜感激。 检查出来:如何格式化Microsoft JSON日期? var date = new Date(parseInt(jsonDate.substr(6)));
Possible Duplicate: How to format a JSON date? Parsing Date from webservice Sorry if this question has already been asked. I have look around but have been unable to find one. Is there a quick and convenient way to convert a "json" date into a human friendly format using only javascript and jQuery (excluding additional jQuery libraries)? The date is format is the following: c
可能重复: 如何格式化JSON日期? 从webservice解析日期 对不起,如果这个问题已经被问到。 我环顾四周,但一直无法找到。 有没有一种简单快捷的方法,只需使用javascript和jQuery (不包括额外的jQuery库)将“json”日期转换为人性化的格式? 日期格式如下: creationDate: "/Date(1346713200000+0100)/" 谢谢 > var maybeDateString = "/Date(1346713200000+0100)/"; > fromDateString(maybeDateString) Tue
Possible Duplicate: How to format a JSON date? I am calling a JSON web service via Javascript, and the StartDate field is /Date(1268524800000)/ . How do I convert this to a human readable format?d Try this: var str = "/Date(1268524800000)/"; var num = parseInt(str.replace(/[^0-9]/g, "")); var date = new Date(num); alert(date); Fiddle: http://jsfiddle.net/dS2hd/ You can use a regex to g
可能重复: 如何格式化JSON日期? 我正在通过Javascript调用JSON Web服务,并且StartDate字段是/Date(1268524800000)/ 。 如何将其转换为可读格式?d 尝试这个: var str = "/Date(1268524800000)/"; var num = parseInt(str.replace(/[^0-9]/g, "")); var date = new Date(num); alert(date); 小提琴:http://jsfiddle.net/dS2hd/ 您可以使用正则表达式来获取毫秒,然后使用Date构造函数来获取Date对象。 一旦你有
This question already has an answer here: How do I format a Microsoft JSON date? 37 answers Duplicate of How to format a JSON date?. Accepted solution was: var date = new Date(parseInt(jsonDate.substr(6))); Try something like this:- var d = new Date(unix_timestamp*1000); or var d = new Date([UNIX Timestamp] * 1000); Date构造函数接受Unix时间戳。 function cleanDate(d) { return ne
这个问题在这里已经有了答案: 如何格式化Microsoft JSON日期? 37个答案 重复如何格式化JSON日期? 接受的解决方案是: var date = new Date(parseInt(jsonDate.substr(6))); 尝试这样的事情: - var d = new Date(unix_timestamp*1000); 要么 var d = new Date([UNIX Timestamp] * 1000); Date构造函数接受Unix时间戳。 function cleanDate(d) { return new Date(+d.replace(//Date((d+))//, '$1')); } cl
Possible Duplicate: Format a Microsoft JSON date? The ASP.NET function Json() formats and returns a date as {"d":"/Date(1240718400000)/"} which has to be dealt with on the client side which is problematic. What are your suggestions for approaches to sending date values back and forth? This was found in another post on Stack Overflow: var date = new Date(parseInt(jsonDate.substr(6)));
可能重复: 格式化Microsoft JSON日期? ASP.NET函数Json()格式化并返回一个日期 {"d":"/Date(1240718400000)/"} 必须在客户端处理,这是有问题的。 对于来回发送日期值的方法,您有什么建议? 这发现在Stack Overflow的另一篇文章中: var date = new Date(parseInt(jsonDate.substr(6))); substr函数取出“/ Date(”部分,parseInt函数获取整数并在最后忽略“)/”。 生成的数字被传入Date构造函数。 如果你不绑定
Possible Duplicate: How to format a JSON date? I have the following result from a $getJSON call from JavaScript. How do I convert the start property to a proper date in JavaScript? [ {"id":1,"start":"/Date(1238540400000)/"}, {"id":2,"start":"/Date(1238626800000)/"} ] Thanks! You need to extract the number from the string, and
可能重复: 如何格式化JSON日期? 我从JavaScript的$ getJSON调用中得到以下结果。 如何在JavaScript中将启动属性转换为适当的日期? [{“id”:1,“start”:“/ Date(1238540400000)/”},{“id”:2,“start”:“/ Date(1238626800000)/”}] 谢谢! 您需要从字符串中提取数字,并将其传递到Date constructor : var x = [{ "id": 1, "start": "/Date(1238540400000)/" }, { "id": 2, "start": "/Date(1
My server app returns a timestamp string which is in UTC. Now I want to convert it to a date object to get the local datetime, then convert that date object back to timestamp to get the local timestamp. This doesn't seem to work as both strings outputted are identical console.log(JSON.stringify(timestamp)); var date = new Date(timestamp*1000).getTime(); console.log(JSON.stringify(date));
我的服务器应用程序返回UTC格式的时间戳字符串。 现在我想将其转换为日期对象以获取本地日期时间,然后将该日期对象转换回时间戳以获取本地时间戳。 这似乎不起作用,因为两个输出的字符串都是相同的 console.log(JSON.stringify(timestamp)); var date = new Date(timestamp*1000).getTime(); console.log(JSON.stringify(date)); 我如何解决这个问题? 你需要使用时间戳创建一个新的Date实例(我认为它已经是一个格式