简体   繁体   English

c# 中的 UTC 时间格式

[英]UTC time format in c#

I need to set expire date of product as present date till midnight as shown below in UTC format.我需要将产品的到期日期设置为当前日期,直到午夜,如下所示,以 UTC 格式显示。

"2021-05-28T23:59:59Z" “2021-05-28T23:59:59Z”

How i can write this in C#.我怎么能在 C# 中写这个。

Use DateTime.UtcNow.Date使用DateTime.UtcNow.Date

DateTime.UtcNow.Date.AddDays(1).AddSeconds(-1).ToString("o")

The output of above is上面的 output 是

2021-05-28T23:59:59.0000000Z 2021-05-28T23:59:59.0000000Z

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

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