簡體   English   中英

為什么 c# 中的日期結果與 ActionScript 不同?

[英]why is the date result in c# different then ActionScript?

我想在 c# 中獲取日期 utc 但 c# 中的結果不同

ActionScript

var date = new Date();
date.fullYearUTC
date.monthUTC
date.dateUTC

結果

2020 3 9

在 c#

DateTime.UtcNow.Year
DateTime.UtcNow.Month
DateTime.UtcNow.Date

結果

2020 4 09.04.2020 00:00:00

UtcNow 是錯誤的方式嗎?
謝謝你的幫助!

ActionScript 以 0 表示 1 月,3 表示 4 月等。而 C# 以 1 表示 1 月,4 表示 4 月等。這解釋了月份的差異。 The difference in output for the output for days in C# is that to get the day of the month in C# you say DateTime.UTCNow.UTCNow.Day for example, instead of DateTime.UTCNow.Date , which tries to output the whole date rather不僅僅是一天。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM