shashank shekhar
shashank shekhar

Reputation: 162

Convert in UTC time format in c#

I need to set expire date of product as present date till midnight as shown below in UTC format.

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

How i can write this in C#.

Upvotes: 0

Views: 1915

Answers (1)

user1672994
user1672994

Reputation: 10849

Use DateTime.UtcNow.Date

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

The output of above is

2021-05-28T23:59:59.0000000Z

Upvotes: 2

Related Questions