简体   繁体   English

Angular2 / Typescript:如何将Javascript / Typescript日期转换为C#DateTime客户端的字符串表示形式

[英]Angular2/Typescript: How to convert a Javascript/Typescript Date to a String representation of C# DateTime client side

我正在忙于Angular2 / Typescript项目,在该项目中我需要将日期发送到C#后端...我已经读了很多书,但通过谷歌搜索只能找到如何在后端转换日期...我尝试的最后一件事是toIsoString()javascript方法,但是即使它在控制台中看起来正确也没有用...我知道如何解决这个问题吗?

/// <reference path="definition/jquery/jquery.d.ts" />

$('document').ready(function(){
    let myDate: Date = new Date();
    let dateString = myDate.toISOString();
    console.log(dateString);
});

output will be 2017-02-13T13:08:07.966Z what you should interpret in c# 输出将是2017-02-13T13:08:07.966Z您应该在C#中解释的内容

perhaps the problem is to interpret this string with c#, there i cant help 也许问题是用C#解释这个字符串,我帮不上忙

我设法使其最终运行的方式...

this.invoice.InvoiceDate = "/Date(" + new Date(invoice.InvoiceDate).toISOString() + ")/";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM