简体   繁体   中英

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

I want to get date utc in c# but the result in c# is different

ActionScript

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

Result

2020 3 9

in c#

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

Result

2020 4 09.04.2020 00:00:00

is UtcNow the wrong way?
thanxs for helping!

ActionScript starts months at 0 for January, 3 for April, etc. whereas C# starts at 1 for January, 4 for April, etc. That explains the difference in the months. 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 than just the day.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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