将.NET DateTime对象转换为Javascript Date对象

编程入门 行业动态 更新时间:2024-10-26 05:22:01
本文介绍了将.NET DateTime对象转换为Javascript Date对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我遇到以下问题:

我从SQL Server中检索DateTime对象,并将其通过JSON(使用$ .ajax)传递给Javascript.我在尝试将检索到的对象转换为javascript中的Date对象时遇到了困难. 检索到的对象是值"/Date(615592800000)/"的字符串.我认为这是一个时代.

I retrieve a DateTime object from SQL Server and pass it via JSON (using $.ajax) to Javascript. I have experienced difficulty trying to convert the retrieved object to a Date object in javascript. The retrieved object is a string of value "/Date(615592800000)/". I think the value is an epoch time.

我的问题是,除了使用正则表达式选择时期值然后创建一个新的Date对象,还有别的检索日期对象的方法吗?

My question is, is there another way of retrieving the date object than to use regex to select the epoch value and then create a new Date object?

我是JS的新手,所以我们将不胜感激.

I'm fairly new to JS, so any help would be appreciated.

推荐答案

我不知道...这是我正在使用的功能,以防万一...

not that I know... this is the function i'm using, just in case ...

function toDateFromJson(src) { return new Date(parseInt(src.substr(6))); }

更多推荐

将.NET DateTime对象转换为Javascript Date对象

本文发布于:2023-11-04 12:11:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557906.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对象   转换为   DateTime   NET   Javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!